Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
PDFKit.GetPDFPageImage
Renders an image of a page in a PDF document.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
PDFKit | 2.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
A container value with the PDF content from a media field. Or a text with an URL. Or a PDF reference from PDFKit.Open. | |||
index | The index of the page. From zero to PDFKit.GetPDFPageCount-1. |
0 | |
ImageType | The type of image to return. Either JPEG, PNG, GIF or BMP. Default is JPEG. |
"JPEG" | Optional |
FileName | The filename to use for the picture. Default is "image" with the extension matching the image type. |
"test.jpg" | Optional |
DPI | The DPI to use for the resolution of the image. Default is 72. | 72 | Optional |
box | The PDF box to use. Can be Media Box = 0, Crop Box = 1, Bleed Box = 2, TrimBox = 3 or ArtBox = 4. If the box is not defined, we fall back to the media box. Default is 0. | 1 | Optional |
ClearBackground | Optionally, whether to have a transparent background (1) vs. a white background (0). Default is 0 for white. For JPEG, you can't pass 1. |
0 | Optional |
Result
Returns a container with a JPEG picture of the PDF page. You can store it in a media field.
Description
Renders an image of a page in a PDF document.With plugin version 2.4 you can specify format with ImageType parameter.
Due to bugs in Apple’s PDFKit you may see memory leaks with JPEG data from PDF pages (seen in macOS 10.12).
For Windows, Linux or iOS, please check DynaPDF.RenderPage or DynaPDF.GeneratePreview function.
If you only need Windows, please check WinPDF.PageImage function.
See Plugin.SetPreviewSize to control size of preview picture.
Examples
Render page 2 of a PDF into a picture
MBS( "PDFKit.GetPDFPageImage"; $ref; 1; "jpeg"; "test.jpg"; 300; 1 )
Render first page of a PDF in a container:
MBS( "PDFKit.GetPDFPageImage"; TableName::ContainerFieldName; 0; "jpeg"; "image.jpg" )
Make preview of page:
If [ MBS("IsWindows") ]
Set Variable [ $pdf ; Value: MBS( "WinPDF.LoadContainer"; Get Preview::Input) ]
If [ MBS("IsError") = 0 ]
Set Variable [ $NewImage ; Value: MBS( "WinPDF.PageImageAtSize"; $pdf; 0; 0; 600; "JPEG"; "page.jpg") ]
If [ MBS("IsError") = 0 ]
Set Field [ Get Preview::Preview ; $NewImage ]
Set Field [ Get Preview::Made using ; "WinPDF" ]
Set Variable [ $r ; Value: MBS( "WinPDF.Release"; $pdf) ]
Exit Script [ Text Result: ]
End If
Set Variable [ $r ; Value: MBS( "WinPDF.Release"; $pdf) ]
End If
Else If [ MBS("IsMacOS") or MBS("IsIOS") ]
Set Variable [ $preview ; Value: MBS( "PDFKit.GetPDFPageImage"; $Input; 0; "JPEG"; "input.jpg"; 72) ]
If [ MBS("IsError") = 0 ]
Set Field [ Get Preview::Preview ; $preview ]
Set Field [ Get Preview::Made using ; "PDFKit" ]
Exit Script [ Text Result: ]
End If
End If
See also
- PDFKit.GetPDFPageCount
- PDFKit.GetPDFPagePDF
- PDFKit.GetPDFPagePDFRef
- PDFKit.GetPDFPagesPDF
- PDFKit.GetPDFPageText
- PDFKit.GetPDFPageValue
- PDFKit.Open
- PDFKit.SetPDFPageDisplayAnnotation
- WinPDF.LoadContainer
- WinPDF.PageImage
Release notes
- Version 11.2
- Improved memory usage of Container.ReadImage, PDFKit.GeneratePreview and PDFKit.GetPDFPageImage functions, especially for server.
- Version 9.5
- Fixed problem with returning NSImages. Now passing pixel size to FileMaker, so images with DPI > 72 show correctly in container. e.g. for PDFKit.GetPDFPageImage function.
Example Databases
- Barcode/Barcodes from Invoices
- Containers/Create Container Preview
- Mac and iOS/PDFKit/Extract PDF Pages
- Mac and iOS/PDFKit/PDFKit Page Selector
Blog Entries
- Render pictures from PDF
- MBS FileMaker Plugin, version 11.2pr4
- MBS FileMaker Plugin, version 9.5pr2
- JPEG rendering in MacOS Mojave
- MBS Filemaker Plugin, version 4.0pr1
- MBS Filemaker Plugin 2.4 release notes
- MBS Filemaker Plugin, version 2.4pr2
- MBS Filemaker Plugin, version 2.4pr1
- MBS Filemaker Plugin, version 2.1pr5
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 15th April 2023