Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2   11.3   11.4    Statistic    FMM    Blog  

DynaPDF.GeneratePreview

Adds a preview picture to a PDF container.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 4.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.GeneratePreview"; PDFContainer { ; OnlyImage; ImageName } )   More

Parameters

Parameter Description Example Flags
PDFContainer The input PDF container value. Must contain a PDF file. MyTable::PDFContainer
OnlyImage Default is 0. But if you pass 1, the plugin does not return the PDF data in the result, but only the preview. 0 Optional
ImageName If OnlyImage is 1, you can specify a file name for the image result. "preview.jpg" Optional

Result

Returns updated container value or error.

Description

Adds a preview picture to a PDF container.
On Windows if you have a PDF in a container FileMaker will not show a preview due to a missing PDF rendering library. On macOS the system can show PDF directly and FileMaker uses this.
This function renders first page as JPEG and add it to the container value as preview.
You need to use DynaPDF.Initialize before to load the DynaPDF library and set the license key (Pro required).
With version 5.0 optionally only creates image without passing PDF data back.

Requires DynaPDF Pro license for the raster engine to create bitmaps from PDF pages.
See also DynaPDF.RenderPage for more options on rendering.

On macOS the PDFKit.GeneratePreview function can be an alternative way, but limited to the capabilities of Apple’s frameworks.

Examples

Add a preview to PDF container

# does container have jpeg preview?
If [MBS( "Container.GetTypeSize" ; test::pdf; "JPEG") <= 0]
    # Add preview to PDF in container
    Set Field [test::pdf; MBS("DynaPDF.GeneratePreview"; test::pdf)]
End If

Add a preview to PDF container if needed:

# get a PDF somewhere
Set Variable [ $PDF ; Value: MBS( "Files.ReadFile"; "C:\Users\Christian\Desktop\test.pdf"; "auto") ]
# Does have PDF and no image?
Set Variable [ $types ; Value: MBS( "Container.GetTypes"; $PDF) ]
# PDF included?
If [ Position ( $types ; "PDF " ; 1 ; 1 ) > 0 ]
    # Image preview missing?
    If [ Position ( $types ; "JPEG" ; 1 ; 1 ) < 1 and Position ( $types ; "PNGf" ; 1 ; 1 ) < 1 ]
        # Use DynaPDF if initialized, we can use it
        If [ MBS( "DynaPDF.IsInitialized" ) ]
            Set Variable [ $PDF2 ; Value: MBS( "DynaPDF.GeneratePreview"; $PDF) ]
            If [ MBS("IsError") = 0 ]
                # Success, so use the new PDF
                Set Variable [ $PDF ; Value: $PDF2 ]
            End If
        Else If [ MBS( "IsMacOSX" ) = 1 ]
            # On Mac use PDFKit
            Set Variable [ $PDF2 ; Value: MBS( "PDFKit.GeneratePreview"; $PDF) ]
            If [ MBS("IsError") = 0 ]
                # Success, so use the new PDF
                Set Variable [ $PDF ; Value: $PDF2 ]
            End If
        End If
    End If
End If
# Store PDF with preview
Set Field [ test::Image ; $PDF ]

See also

Example Databases

Blog Entries

Created 18th August 2014, last changed 10th August 2020


DynaPDF.FreeTextAnnot - DynaPDF.GetAnnotCount

Feedback: Report problem or ask question.




Links
MBS Xojo blog

Start Chat