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:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
Queries page size for an import PDF page.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 3.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
The PDF reference returned from DynaPDF.New. | |||
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 |
Returns rectangle as string with four numbers for left, top, right and bottom.
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) ]
Created 18th August 2014, last changed 21st March 2021
DynaPDF.GetImportPDFVersion - DynaPDF.GetImportPageCount
Feedback: Report problem or ask question.