DynaPDF.OpenPDFFromContainer
----------------------------

Opens a PDF for importing from a container.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [3.0](newinversion30.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.OpenPDFFromContainer"; PDF; ContainerValue { ; PasswordType; Password } ) 

**MBS**( **"DynaPDF.OpenPDFFromContainer";** /\* Opens a PDF for importing from a container. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$ContainerValue**; /\* The container value to use. Should contain a PDF file.e.g. $PDF \*/   
**$PasswordType**; /\* Optional; 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.e.g. 0 \*/   
**$Password**) /\* Optional; The password to decrypt the file. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| ContainerValue | The container value to use. Should contain a PDF file. | $PDF |  |
| 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](DynaPDFImportPDFFile.md) or [DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md) to import one or more pages. Or just check metadata with e.g. [DynaPDF.GetImportDocInfo](DynaPDFGetImportDocInfo.md) and check page count and sizes with [DynaPDF.GetImportPageBounds](DynaPDFGetImportPageBounds.md) and [DynaPDF.GetImportPageCount](DynaPDFGetImportPageCount.md).  
  
If you use [Container.ReadFile](ContainerReadFile.md) to read PDF and then pass it to DynaPDF.OpenPDFFromContainer, please consider to use [DynaPDF.OpenPDFFromFile](DynaPDFOpenPDFFromFile.md) instead to avoid extra memory usage and avoid FileMaker rendering a preview picture for the PDF.  
See also [OpenPDFFromContainer](https://www.monkeybreadsoftware.com/DynaPDF-Manual/OpenImportBuffer.shtml) function in DynaPDF manual.

### Examples

Opens PDF:

 $r = MBS ( "DynaPDF.OpenPDFFromContainer"; $PDF ; $PDFFile )  
$error = MBS ( "[DynaPDF.GetLastErrorMessage](DynaPDFGetLastErrorMessage.md)"; $PDF )  
Load PDF and extract text of page 2:

 # initialize DynaPDF before running this:   
Set Variable \[$pdf ; Value:MBS ("[DynaPDF.New](DynaPDFNew.md)")\]  
\# load PDF from container   
Set Variable \[$r ; Value:MBS ("DynaPDF.OpenPDFFromContainer";$pdf ; Test::data )\]  
\# import all pages   
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)";$pdf )\]  
\# extra text of page 2   
Set Field \[Test::PageText ; MBS ("[DynaPDF.ExtractPageText](DynaPDFExtractPageText.md)"; $pdf ; 2)\]  
\#Cleanup   
Set Variable \[$r ; Value:MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf )\]  
Import a single page:

 Set Variable \[$r ; Value:MBS ("[DynaPDF.SetImportFlags](DynaPDFSetImportFlags.md)"; $pdf ; "ImportAll ImportAsPage")\]  
Set Variable \[$r ; Value:MBS ("DynaPDF.OpenPDFFromContainer"; $pdf ; Invoice::PDF Template)\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; 1)\]  
Import selected pages from one PDF and write into a new one:

 # New PDF   
Set Variable \[$pdf ; Value:MBS ("[DynaPDF.New](DynaPDFNew.md)")\]  
  
\# Open existing PDF file (or use DynaPDF.OpenPDFFromContainer for container)   
Set Variable \[$r ; Value:MBS ("[DynaPDF.OpenPDFFromFile](DynaPDFOpenPDFFromFile.md)"; $pdf ; $path )\]  
  
\# Query page count   
Set Variable \[$pageCount ; Value:MBS ( "[DynaPDF.GetImportPageCount](DynaPDFGetImportPageCount.md)"; $pdf )\]  
  
\# Import the pages you need   
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; 1)\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; 2)\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; 3)\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; $pagecount - 1)\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; $pagecount - 2)\]  
  
\# Set output to this file path   
\# MBS ( "[DynaPDF.OpenOutputFile](DynaPDFOpenOutputFile.md)"; $pdf ; "/Users/cs/Desktop/output.pdf" )   
  
\# Write PDF   
Set Variable \[$r ; Value:MBS ("[DynaPDF.Save](DynaPDFSave.md)"; $pdf )\]  
  
\# release memory   
Set Variable \[$r1 ; Value:MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf )\]  
Query width and height of first page in PDF:

 # Initialize DynaPDF if needed   
If \[ MBS ("[DynaPDF.IsInitialized](DynaPDFIsInitialized.md)") ≠ 1 \]   
 Perform Script \[ Specified: From list ; “Initialize DynaPDF” ; Parameter: \]  
End If  
\# Clear current PDF document   
Set Variable \[ $pdf ; Value: MBS ("[DynaPDF.New](DynaPDFNew.md)") \]   
\#   
\# 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](DynaPDFGetImportPageBounds.md)"; $pdf ; 1; "MediaBox") \]   
\#   
\# split numbers, may need special handling with [Math.TextToNumber](MathTextToNumber.md) to make sure it works if you use comma as decimal separator:   
\#   
Set Variable \[ $left ; Value: MBS ( "[Math.TextToNumber](MathTextToNumber.md)"; GetValue($PageSize ; 1)) \]   
Set Variable \[ $top ; Value: MBS ( "[Math.TextToNumber](MathTextToNumber.md)"; GetValue($PageSize ; 2)) \]   
Set Variable \[ $right ; Value: MBS ( "[Math.TextToNumber](MathTextToNumber.md)"; GetValue($PageSize ; 3)) \]   
Set Variable \[ $bottom ; Value: MBS ( "[Math.TextToNumber](MathTextToNumber.md)"; 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](DynaPDFRelease.md)"; $pdf ) \]  
### See also

- [DynaPDF.RotateCoords](DynaPDFRotateCoords.md)
- [DynaPDF.RotateTemplate](DynaPDFRotateTemplate.md)
- [DynaPDF.Save](DynaPDFSave.md)
- [DynaPDF.SetImportFlags](DynaPDFSetImportFlags.md)
- [DynaPDF.SetImportFlags2](DynaPDFSetImportFlags2.md)
- [DynaPDF.SetMetadata](DynaPDFSetMetadata.md)
- [DynaPDF.SetUseGlobalImpFiles](DynaPDFSetUseGlobalImpFiles.md)
- [DynaPDF.WebLink](DynaPDFWebLink.md)
- [DynaPDF.WriteFTextEx](DynaPDFWriteFTextEx.md)
- [Math.TextToNumber](MathTextToNumber.md)

### Release notes

- **Version 14.5**
    - Improved [DynaPDF.GeneratePreview](https://www.mbsplugins.eu/DynaPDFGeneratePreview.shtml), [DynaPDF.ReadImageResolution](https://www.mbsplugins.eu/DynaPDFReadImageResolution.shtml), [DynaPDF.ReadImageFormat](https://www.mbsplugins.eu/DynaPDFReadImageFormat.shtml), [DynaPDF.InsertImage](https://www.mbsplugins.eu/DynaPDFInsertImage.shtml), [DynaPDF.AttachFileContainer](https://www.mbsplugins.eu/DynaPDFAttachFileContainer.shtml), [DynaPDF.AddOutputIntentEx](https://www.mbsplugins.eu/DynaPDFAddOutputIntentEx.shtml), [DynaPDF.CreateICCBasedColorSpaceContainer](https://www.mbsplugins.eu/DynaPDFCreateICCBasedColorSpaceContainer.shtml) and [DynaPDF.OpenPDFFromContainer](https://www.mbsplugins.eu/DynaPDFOpenPDFFromContainer.shtml) to return proper error if container is empty.

### Example Databases

- [DynaPDF/Add Weblinks](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Add%20Weblinks.shtml#3ScriptAnchor_)
- [DynaPDF/Book Creation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Book%20Creation.shtml#3ScriptAnchor_)
- [DynaPDF/Change Separation Colorant](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Change%20Separation%20Colorant.shtml#2ScriptAnchor_)
- [DynaPDF/Extract and analyze images](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Extract%20and%20analyze%20images.shtml#2ScriptAnchor_)
- [DynaPDF/Extract Attachments](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Extract%20Attachments.shtml#2ScriptAnchor_)
- [DynaPDF/Fill Form Fields](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Fill%20Form%20Fields.shtml#1ScriptAnchor_)
- [DynaPDF/Optimize PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Optimize%20PDF.shtml#2ScriptAnchor_)
- [DynaPDF/PDF Differences](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/PDF%20Differences.shtml#1ScriptAnchor_)
- [DynaPDF/Print PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Print%20PDF.shtml#2ScriptAnchor_)
- [DynaPDF/Replace Text](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Replace%20Text.shtml#2ScriptAnchor_)

### Blog Entries

- [Make PDF certificates in calculation with DynaPDF](https://www.mbsplugins.de/archive/2026-05-18/Make_PDF_certificates_in_calcu/monkeybreadsoftware_blog_filemaker)
- [Retract text from a PDF with DynaPDF](https://www.mbsplugins.de/archive/2025-11-01/Retract_text_from_a_PDF_with_D/monkeybreadsoftware_blog_filemaker)
- [Electronic invoices in FileMaker](https://www.mbsplugins.de/archive/2025-03-06/Electronic_invoices_in_FileMak/monkeybreadsoftware_blog_filemaker)
- [Elektronische Rechnungen in FileMaker](https://www.mbsplugins.de/archive/2025-03-04/Elektronische_Rechnungen_in_Fi/monkeybreadsoftware_blog_filemaker)
- [How the Script Merges PDFs and Inserts an Image: A Detailed Breakdown](https://www.mbsplugins.de/archive/2025-02-16/How_the_Script_Merges_PDFs_and/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Advent calendar - Door 10 - Reading The Wish List](https://www.mbsplugins.de/archive/2024-12-10/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Advent calendar - Door 4 - Add GTC with DynaPDF](https://www.mbsplugins.de/archive/2024-12-04/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Extract invoice for ZUGFeRD and Facture-X](https://www.mbsplugins.de/archive/2024-09-20/Extract_invoice_for_ZUGFeRD_an/monkeybreadsoftware_blog_filemaker)
- [PDF Attachments in FileMaker with DynaPDF](https://www.mbsplugins.de/archive/2024-01-29/PDF_Attachments_in_FileMaker_w/monkeybreadsoftware_blog_filemaker)
- [DynaPDF Parser for FileMaker](https://www.mbsplugins.de/archive/2024-01-19/DynaPDF_Parser_for_FileMaker/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2022, Seite 33](https://filemaker-magazin.de/neuigkeit/4191-Appetithappen-FMM_202204)
- [Ausgabe 5/2021, Seite 26](https://filemaker-magazin.de/neuigkeit/4158-Appetithappen-FMM_202105)
- [Ausgabe 6/2020, Seite 34](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)
- [Ausgabe 6/2020, Seite 32](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)
- [Ausgabe 3/2019, Seite 37](https://filemaker-magazin.de/neuigkeit/4046-Appetithappen-FMM_201903)
- [Ausgabe 2/2019, Seite 27](https://filemaker-magazin.de/neuigkeit/4043-Appetithappen-FMM_201902)
- [Ausgabe 2/2019, Seite 25](https://filemaker-magazin.de/neuigkeit/4043-Appetithappen-FMM_201902)
- [Ausgabe 1/2018, Seite 24 bis 26](https://filemaker-magazin.de/neuigkeit/3981-Appetithappen-FMM_201801)
- [Ausgabe 6/2017, Seite 26](https://filemaker-magazin.de/neuigkeit/3967-Appetithappen-FMM_201706)
- [Ausgabe 6/2016, Seite 24](https://filemaker-magazin.de/neuigkeit/3913-Appetithappen-FMM_201606)

This function checks for a license.

Created 18th August 2014 , last changed 28th May 2021

  
[DynaPDF.OpenOutputFileEncrypted](DynaPDFOpenOutputFileEncrypted.md) - [DynaPDF.OpenPDFFromFile](DynaPDFOpenPDFFromFile.md)

[HTML Version](DynaPDFOpenPDFFromContainer.shtml)