Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

DynaPDF.GetImportPageBounds

Queries page size for an import PDF page.

Component Version macOS Windows Linux Server iOS SDK
DynaPDF 3.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "DynaPDF.GetImportPageBounds"; PDF; PageIndex { ; Box } )   More

Parameters

Parameter Description Example Flags
PDF The PDF reference returned from DynaPDF.New. $pdf
PageIndex The page index in range from 1 to DynaPDF.GetImportPageCount. 1
Box Optional, which box to use. Default is Mediabox. You can pass MediaBox, CropBox, ArtBox, BleedBox or TrimBox. "MediaBox" Optional

Result

Returns rectangle as string with four numbers for left, top, right and bottom.

Description

Queries page size for an import PDF page.
Please note that we have DynaPDF.GetPageBBox for the current working PDF and the DynaPDF.GetImportPageBounds for the current open import PDF.

See also GetImportPageBounds function in DynaPDF manual.

Examples

Queries crop size of page 5 from import PDF:

$r = MBS( "DynaPDF.GetImportPageBounds"; $PDF; 5; "CropBox" )

Query width and height of first page in PDF:

# Initialize DynaPDF if needed
If [ MBS("DynaPDF.IsInitialized") ≠ 1 ]
    Perform Script [ Specified: From list ; “Initialize DynaPDF” ; Parameter: ]
End If
# Clear current PDF document
Set Variable [ $pdf ; Value: MBS("DynaPDF.New") ]
#
# Load PDF from container
#
Set Variable [ $r ; Value: MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Test::PDF artwork) ]
#
# Query page size for the first page:
#
Set Variable [ $PageSize ; Value: MBS("DynaPDF.GetImportPageBounds"; $pdf; 1; "MediaBox") ]
#
# split numbers, may need special handling with Math.TextToNumber to make sure it works if you use comma as decimal separator:
#
Set Variable [ $left ; Value: MBS( "Math.TextToNumber"; GetValue($PageSize; 1)) ]
Set Variable [ $top ; Value: MBS( "Math.TextToNumber"; GetValue($PageSize; 2)) ]
Set Variable [ $right ; Value: MBS( "Math.TextToNumber"; GetValue($PageSize; 3)) ]
Set Variable [ $bottom ; Value: MBS( "Math.TextToNumber"; GetValue($PageSize; 4)) ]
#
Set Variable [ $Width ; Value: Abs($right - $left) ]
Set Variable [ $height ; Value: Abs($top- $bottom) ]
#
# Calculate in centimeters
#
Set Field [ Test::Job dimension horizontal ; Round($Width * 2.54 / 72; 2) ]
Set Field [ Test::Job dimension vertical ; Round($Height * 2.54 / 72; 2) ]
#
# Cleanup
Set Variable [ $r ; Value: MBS("DynaPDF.Release"; $pdf) ]

See also

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 21st March 2021


DynaPDF.GetImportPDFVersion - DynaPDF.GetImportPageCount