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.0   9.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3    Statistic  

DynaPDF.RenderPage

Renders a page in current PDF to an image.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
DynaPDF 3.0 Yes Yes Yes Yes Yes
MBS( "DynaPDF.RenderPage"; PDF; PageIndex; Resolution; Width; Height; Flags; PixelFormat; Filter; Format { ; Filename; DestPath } )   More

Parameters

Parameter Description Example value
PDF The PDF reference returned from DynaPDF.New. $pdf
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
Width The width of the output image. Can be zero to use page width or to scale based on height. 800
Height The height of the output image. Can be zero to use page height or to scale based on width. 600
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"
0
PixelFormat The pixel format. Can be 1bit, gray, RGB, BGR, RGBA, BGRA, ARGB, ABGR, CMYK, CMYKA and GrayA. Default is RGB. "RGB"
Filter The compression filter to use. Can be Flate, JPEG, CCITT3, CCITT4, LZW or JP2K. Default is JPEG. "JPEG"
Format The image format to use. Can be TIFF, JPEG, PNG, BMP or JPC. Default is JPEG. "JPEG"
Filename Optional
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
DestPath Optional
Optional, a file path for storing image instead of a container.
"/Users/cs/Desktop/test.jpg"

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.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.

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))

See also

Example Databases

Blog Entries

Release notes

  • Version 10.1
    • Fixed problem with DynaPDF.RenderPage not returning container if you pass empty file path parameter.

Created 18th August 2014, last changed 26th June 2020


DynaPDF.RenderPDFFileEx   -   DynaPDF.ReplaceImage

Feedback: Report problem or ask question.




Links
MBS Xojo PDF Plugins