DynaPDF.OpenPDFFromFile
-----------------------

Opens a PDF for importing from a file.

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

MBS( "DynaPDF.OpenPDFFromFile"; PDF; Path { ; PasswordType; Password } ) 

**MBS**( **"DynaPDF.OpenPDFFromFile";** /\* Opens a PDF for importing from a file. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Path**; /\* The path to use. Should contain a PDF file. \*/   
**$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 |  |
| Path | The path to use. Should contain a PDF file. | $path |  |
| 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 0, file handle or error message.

### Description

Opens a PDF for importing from a file.  
Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required.  
If you have the PDF in a container, please use [DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md) function instead.  
  
Requires DynaPDF Lite license.  
  
If the function succeeds the return value is zero or the file handle if the flag UseProxy is set (a value greater or equal zero). If the function fails the return value is an error message.   
  
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).  
See also [OpenPDFFromFile](https://www.monkeybreadsoftware.com/DynaPDF-Manual/OpenImportFile.shtml) function in DynaPDF manual.

### Examples

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](DynaPDFOpenPDFFromContainer.md) for container)   
Set Variable \[$r ; Value:MBS ("DynaPDF.OpenPDFFromFile"; $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 )\]  
Import a single page:

 Set Variable \[$r ; Value:MBS ("[DynaPDF.SetImportFlags](DynaPDFSetImportFlags.md)"; $pdf ; "ImportAll ImportAsPage")\]  
Set Variable \[$r ; Value:MBS ("DynaPDF.OpenPDFFromFile; $pdf ; "C:\\test.pdf")\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; 1)\]  
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.OpenPDFFromFile";$pdf ; "/Users/cs/Desktop/test.pdf")\]  
\# 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 )\]  
Read in a file, add text and write back:

 # Start new PDF   
Set Variable \[ $pdf ; Value: MBS ("[DynaPDF.New](DynaPDFNew.md)") \]  
\#   
\# import existing file   
Set Variable \[ $r ; Value: MBS ("DynaPDF.OpenPDFFromFile"; $pdf ; "/Users/cs/Temp/Installation.pdf") \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)"; $pdf ; 1) \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.CloseImportFile](DynaPDFCloseImportFile.md)"; $pdf ) \]  
\#   
\# now edit a page   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EditPage](DynaPDFEditPage.md)"; $pdf ; 1) \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetFont](DynaPDFSetFont.md)"; $pdf ; "Helvetica"; 0; 20) \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 100; "Hello World") \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf ) \]  
\#   
\# save back to same file   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.OpenOutputFile](DynaPDFOpenOutputFile.md)"; $pdf ; "/Users/cs/Temp/Installation.pdf") \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Save](DynaPDFSave.md)"; $pdf ) \]  
\#   
\# cleanup   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf ) \]  
### See also

- [DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)
- [DynaPDF.Initialize](DynaPDFInitialize.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.OpenOutputFile](DynaPDFOpenOutputFile.md)
- [DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)
- [DynaPDF.Optimize](DynaPDFOptimize.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.Save](DynaPDFSave.md)
- [DynaPDF.SetUseGlobalImpFiles](DynaPDFSetUseGlobalImpFiles.md)
- [DynaPDF.WriteText](DynaPDFWriteText.md)

### Example Databases

- [DynaPDF/Batch Preview](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Batch%20Preview.shtml#3ScriptAnchor_)
- [DynaPDF/Create Text as PDFA](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20Text%20as%20PDFA.shtml#9ScriptAnchor_)
- [DynaPDF/Form/Form](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Form/Form.shtml#3ScriptAnchor_)
- [DynaPDF/Merge PDFs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Merge%20PDFs.shtml#2ScriptAnchor_)
- [DynaPDF/Tables](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Tables.shtml#3ScriptAnchor_)

### 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)
- [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)
- [MBS FileMaker Advent calendar - Door 6 - Sending Out Wishlist Forms](https://www.mbsplugins.de/archive/2024-12-06/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)
- [MBS Plugin Advent calendar: 15 - DynaPDF](https://www.mbsplugins.de/archive/2023-12-15/MBS_Plugin_Advent_calendar_15_/monkeybreadsoftware_blog_filemaker)
- [Things you can do with DynaPDF](https://www.mbsplugins.de/archive/2021-07-02/Things_you_can_do_with_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [Merge PDF with table of contents](https://www.mbsplugins.de/archive/2020-02-25/Merge_PDF_with_table_of_conten/monkeybreadsoftware_blog_filemaker)
- [Create two page PDF document in FileMaker](https://www.mbsplugins.de/archive/2019-08-22/Create_two_page_PDF_document_i/monkeybreadsoftware_blog_filemaker)
- [PDF Forms with MBS Plugin](https://www.mbsplugins.de/archive/2018-04-21/PDF_Forms_with_MBS_Plugin/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2022, Seite 33](https://filemaker-magazin.de/neuigkeit/4191-Appetithappen-FMM_202204)
- [Ausgabe 1/2022, Seite 22](https://filemaker-magazin.de/neuigkeit/4172-Appetithappen-FMM_202201)
- [Ausgabe 1/2022, Seite 19 bis 20](https://filemaker-magazin.de/neuigkeit/4172-Appetithappen-FMM_202201)
- [Ausgabe 5/2021, Seite 27](https://filemaker-magazin.de/neuigkeit/4158-Appetithappen-FMM_202105)
- [Ausgabe 1/2018, Seite 25](https://filemaker-magazin.de/neuigkeit/3981-Appetithappen-FMM_201801)

This function checks for a license.

Created 18th August 2014 , last changed 6th June 2024

  
[DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md) - [DynaPDF.OpenTag](DynaPDFOpenTag.md)

[HTML Version](DynaPDFOpenPDFFromFile.shtml)