Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
DynaPDF.OpenPDFFromContainer
Opens a PDF for importing from a container.
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. | |||
containerValue | The container value to use. Should contain a PDF file. | ||
PasswordType | The password type and flags. Flag kann be 1 for owner password and 0 for open password. You can combine this with 2 to force repair. | 0 | Optional |
Password | The password to decrypt the file. | $password | Optional |
Result
Returns number or error message.
Description
Opens a PDF for importing from a container.Requires DynaPDF Lite license.
On success returns a number ≥ 0.
After opening the file, please use DynaPDF.ImportPDFFile or DynaPDF.ImportPDFPage to import one or more pages. Or just check metadata with e.g. DynaPDF.GetImportDocInfo and check page count and sizes with DynaPDF.GetImportPageBounds and DynaPDF.GetImportPageCount.
If you use Container.ReadFile to read PDF and then pass it to DynaPDF.OpenPDFFromContainer, please consider to use DynaPDF.OpenPDFFromFile instead to avoid extra memory usage and avoid FileMaker rendering a preview picture for the PDF.
See also OpenPDFFromContainer function in DynaPDF manual.
Examples
Opens PDF:
$r = MBS( "DynaPDF.OpenPDFFromContainer"; $PDF; $PDFFile )
$error = MBS( "DynaPDF.GetLastErrorMessage"; $PDF )
Load PDF and extract text of page 2:
# initialize DynaPDF before running this:
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)]
# extra text of page 2
Set Field [Test::PageText; MBS("DynaPDF.ExtractPageText"; $pdf; 2)]
#Cleanup
Set Variable [$r; Value:MBS("DynaPDF.Release"; $pdf)]
Import a single page:
Set Variable [$r; Value:MBS("DynaPDF.SetImportFlags"; $pdf; "ImportAll ImportAsPage")]
Set Variable [$r; Value:MBS("DynaPDF.OpenPDFFromContainer"; $pdf; Invoice::PDF Template)]
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; 1)]
Import selected pages from one PDF and write into a new one:
# New PDF
Set Variable [$pdf; Value:MBS("DynaPDF.New")]
# Open existing PDF file (or use DynaPDF.OpenPDFFromContainer for container)
Set Variable [$r; Value:MBS("DynaPDF.OpenPDFFromFile"; $pdf; $path )]
# Query page count
Set Variable [$pageCount; Value:MBS( "DynaPDF.GetImportPageCount"; $pdf )]
# Import the pages you need
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; 1)]
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; 2)]
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; 3)]
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; $pagecount - 1)]
Set Variable [$r; Value:MBS("DynaPDF.ImportPDFPage"; $pdf; $pagecount - 2)]
# Set output to this file path
# MBS( "DynaPDF.OpenOutputFile"; $pdf; "/Users/cs/Desktop/output.pdf" )
# Write PDF
Set Variable [$r; Value:MBS("DynaPDF.Save"; $pdf)]
# release memory
Set Variable [$r1; Value:MBS("DynaPDF.Release"; $pdf)]
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
- DynaPDF.Release
- DynaPDF.RenderPDFFile
- DynaPDF.ReplaceImage
- DynaPDF.Save
- DynaPDF.SaveAndSignFileExt
- DynaPDF.SetImportFlags
- DynaPDF.SetUseGlobalImpFiles
- DynaPDF.WebLink
- DynaPDF.WriteFTextEx
- Math.TextToNumber
Release notes
- Version 14.5
- Improved DynaPDF.GeneratePreview, DynaPDF.ReadImageResolution, DynaPDF.ReadImageFormat, DynaPDF.InsertImage, DynaPDF.AttachFileContainer, DynaPDF.AddOutputIntentEx, DynaPDF.CreateICCBasedColorSpaceContainer and DynaPDF.OpenPDFFromContainer to return proper error if container is empty.
Example Databases
- DynaPDF/Change Separation Colorant
- DynaPDF/Convert to PDFA
- DynaPDF/Extract Text
- DynaPDF/Merge PDFs
- DynaPDF/PDF Differences
- DynaPDF/PDF Library
- DynaPDF/Print PDF
- DynaPDF/Replace Text
- DynaPDF/ZUGFeRD/ZUGFeRD Invoice
- DynaPDF/ZUGFeRD and Facture-X/ZUGFeRD Rechnung erstellen
Blog Entries
- MBS FileMaker Advent calendar - Door 4 - Add GTC with DynaPDF
- MBS FileMaker Plugin, version 14.5pr8
- Extract invoice for ZUGFeRD and Facture-X
- PDF Attachments in FileMaker with DynaPDF
- DynaPDF Parser for FileMaker
- MBS Plugin Advent calendar: 15 - DynaPDF
- Merge documents with DynaPDF
- Add page links for FileMaker
- Things you can do with DynaPDF
- Render pictures from PDF
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 28th May 2021