Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
DynaPDF.RenderPage
Renders a page in current PDF to an image.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 3.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
The PDF reference returned from DynaPDF.New. | |||
PageIndex | The page number between 1 and DynaPDF.GetPageCount. | 1 | |
Resolution | The resolution you'd like to have for the image. If you pass zero, we use default resolution (72). | 150 | Optional |
Width | The width of the output image. Can be zero to use page width or to scale based on height. | 800 | Optional |
Height | The height of the output image. Can be zero to use page height or to scale based on width. | 600 | Optional |
Flags | Flags for rendering. Use 0 for the default flags. For other values, please look into dynapdf manual. With version 6.4 of our plugin, you can also specify this by passing in text string, e.g. "Rotate90¶ClipToTrimBox" Valid flags: Default, ScaleToMediaBox, IgnoreCropBox, ClipToArtBox, ClipToBleedBox, ClipToTrimBox, ExclAnnotations, ExclFormFields, SkipUpdateBG, Rotate90, Rotate180, Rotate270, InitBlack, CompositeWhite, ExclPageContent, ExclButtons, ExclCheckBoxes, ExclComboBoxes, ExclListBoxes, ExclTextFields, ExclSigFields, ScaleToBBox, DisableAAClipping, DisableAAText, DisableAAVector, DisableAntiAliasing, DisableBiLinearFilter, ClipBoxMask, RenderInvisibleText. Added EnableBlendCS as flag in v12.3. |
0 | Optional |
PixelFormat | The pixel format. Can be 1bit, gray, RGB, BGR, RGBA, BGRA, ARGB, ABGR, CMYK, CMYKA and GrayA. Default is RGB. | "RGB" | Optional |
Filter | The compression filter to use. Can be Flate, JPEG, CCITT3, CCITT4, LZW or JP2K. Default is JPEG. | "JPEG" | Optional |
Format | The image format to use. Can be TIFF, JPEG, PNG, BMP or JPC. Default is JPEG. | "JPEG" | Optional |
Filename | The file name to use for the container value. Default is page with right file extensions for image. Pass any value if you use DestPath parameter. | $name | Optional |
DestPath | Optional, a file path for storing image instead of a container. | "/Users/cs/Desktop/test.jpg" | Optional |
Result
Returns container value with image or error message.
Description
Renders a page in current PDF to an image.You can choose the format and filter, but please make sure they match as not all combinations are valid.
Requires DynaPDF Pro license for the raster engine to create bitmaps from PDF pages.
Please use DynaPDF.InitColorManagement or DynaPDF.InitColorManagementEx to initialize color management, so conversions to other colorspaces like CMYK work better.
You can use DynaPDF.SetPageBBox or DynaPDF.SetBBox to clip the page with the crop box and render only that portion.
If the whole page is just a big picture, you could use DynaPDF.GetImage function to extract it. That would prevent scaling or recompression.
See also RenderPage function in DynaPDF manual.
Examples
Render page 5 with default options:
$ImageData = MBS( "DynaPDF.RenderPage"; $PDF; 5 )
Render page 5 with higher resolution:
$ImageData = MBS( "DynaPDF.RenderPage"; $PDF; 5; 150 )
Render page 5 to file:
$result = MBS( "DynaPDF.RenderPage"; $PDF; 5; 150; 0; 0; 0; "RGB"; "JPEG"; "JPEG"; ""; "/Users/cs/Desktop/test.jpg" )
Open PDF and render page as image to container:
# Start new PDF workspace
Set Variable [$pdf; Value:MBS("DynaPDF.New")]
# Load PDF from container
Set Variable [$r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Test::data)]
# Import all pages
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFFile"; $pdf)]
# Render one page as Picture
Set Variable [$r; Value:MBS("DynaPDF.RenderPage"; $pdf; Test::PageIndex)]
# Put in Container
Set Field [Test::PageImage; $r]
# cleanup
Set Variable [$r; Value:MBS("DynaPDF.Release"; $pdf)]
Render in one formula:
// input: PDFDocumentContainer
Let (
[
~PDFObject = MBS("DynaPDF.New");
~error = MBS("IsError");
~x = MBS("DynaPDF.OpenPDFFromContainer"; ~PDFObject; PDFDocumentContainer);
~error = ~error OR MBS("IsError");
~x = MBS("DynaPDF.ImportPDFPage"; ~PDFObject; 1);
~error = ~error OR MBS("IsError");
~PageIndex = 1;
~Resolution = 150 ;
~Width = 0;
~Height = 0;
~Flags = 0;
~PixelFormat = "RGB";
~Filter = "JPEG";
~Format = "PNG";
~Result = MBS("DynaPDF.RenderPage"; ~PDFObject; ~PageIndex ; ~Resolution; ~Width; ~Height; ~Flags; ~PixelFormat; ~Filter; ~Format);
~error = ~error OR MBS("IsError");
~x = MBS("DynaPDF.Release"; ~PDFObject)];
If(~error; ""; ~Result))
Render page as CMYK to tiff file:
Set Variable [ $r ; Value: MBS("DynaPDF.RenderPage"; $pdf; 1; 300; 0; 0; "default"; "CMYK"; "Flate"; "Tiff"; ""; "/Users/cs/Desktop/test.tif") ]
Loop over pages and make images:
# Start new PDF workspace
Set Variable [$pdf; Value:MBS("DynaPDF.New")]
# Load PDF from container
Set Variable [$r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Test::data)]
# Import all pages
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFFile"; $pdf)]
# loop counting up from 1 to $count
Set Variable [ $count ; Value: MBS( "DynaPDF.GetPageCount"; $pdf ) ]
Set Variable [ $index ; Value: 1 ]
If [ $index ≤ $count ]
Loop
# Render one page as Picture
Set Variable [$r; Value:MBS("DynaPDF.RenderPage"; $pdf; $index)]
# Put in Container
New Record/Request
Set Field [Test::PageImage; $r]
Commit Records/Requests [ With dialog: Off ]
# next
Set Variable [ $index ; Value: $index + 1 ]
Exit Loop If [ $index > $count ]
End Loop
End If
# cleanup
Set Variable [$r; Value:MBS("DynaPDF.Release"; $pdf)]
Render preview of PDF:
# DynaPDF, if initialized?
If [ MBS("DynaPDF.IsInitialized") ]
# Clear current PDF document
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
# Render one page as Picture
Set Variable [ $r ; Value: MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Get Preview::Input) ]
If [ MBS("IsError") = 0 ]
Set Variable [ $r ; Value: MBS("DynaPDF.ImportPDFPage"; $pdf; 1) ]
If [ MBS("IsError") = 0 ]
# now render
Set Variable [ $image ; Value: MBS("DynaPDF.RenderPage"; $pdf; 1; 72) ]
If [ MBS("IsError") = 0 ]
Set Field [ Get Preview::Preview ; $image ]
Set Field [ Get Preview::Made using ; "DynaPDF" ]
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]
Exit Script [ Text Result: ]
End If
End If
End If
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]
End If
See also
- DynaPDF.DeletePage
- DynaPDF.EndPage
- DynaPDF.OpenPDFFromContainer
- DynaPDF.SetBBox
- DynaPDF.SetOCGState
- DynaPDF.SetPageBBox
- GMImage.NewFromContainer
- IsError
- PDFKit.GetPDFPageImage
- WinPDF.PageImage
Release notes
- Version 13.4
- Added ForceInterpolation flag for DynaPDF.RenderPage function.
- Version 10.1
- Fixed problem with DynaPDF.RenderPage not returning container if you pass empty file path parameter.
Example Databases
- Barcode/Barcodes from Invoices
- DynaPDF/Change Separation Colorant
- DynaPDF/Highlight Text
- DynaPDF/List Annotations
- DynaPDF/Live Styled Text
- DynaPDF/PDF Differences
- DynaPDF/PDF Library
- DynaPDF/PSD Conversion
- DynaPDF/Render Page
- DynaPDF/WMF Conversion
Blog Entries
- MBS Plugin 13.4 for Claris FileMaker - More than 7100 Functions In One Plugin
- MBS FileMaker Plugin, version 13.4pr3
- Things you can do with DynaPDF
- Render pictures from PDF
- Windows updates breaks PDF display in FileMaker
- MBS FileMaker Plugin, version 10.1pr1
- MBS FileMaker Plugin, version 6.4pr3
- MBS FileMaker Plugin, version 5.3pr1
- MBS Filemaker Plugin, version 4.5pr4
- Introducing DynaPDF to MBS Filemaker Plugin
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 8th January 2024