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: 9.5   10.0   10.1   10.2   10.3   10.4   10.5   11.0   11.1   11.2    Statistic    FMM    Blog  

PDFKit.GeneratePreview

Adds preview to an existing PDF container.

Component Version macOS Windows Linux Server iOS SDK
PDFKit 7.5 ✅ Yes ❌ No ❌ No ✅ Yes, on macOS ✅ Yes
MBS( "PDFKit.GeneratePreview"; Container )   More

Parameters

Parameter Description Example
Container A media value containing PDF data.

Result

Returns updated container value or error.

Description

Adds preview to an existing PDF container.
For Windows or Linux, please use DynaPDF.GeneratePreview.

Examples

Generate preview:

Set Field [ Merge PDFs::FinalPDF ; MBS("PDFKit.GeneratePreview"; Merge PDFs::InputPDF) ]

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

Release notes

  • Version 11.2
    • Improved memory usage of Container.ReadImage, PDFKit.GeneratePreview and PDFKit.GetPDFPageImage functions, especially for server.
  • Version 7.5

Blog Entries

Created 17th October 2017, last changed 2nd April 2021


PDFKit.CombineRef - PDFKit.GetCurrentFilter

Feedback: Report problem or ask question.




Links
MBS Xojo tutorial videos

Start Chat