DynaPDF.Print
-------------

Prints the PDF file that is currently in memory.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [5.4](newinversion54.md) | ❌ No | ✅ Yes | ❌ No | ✅ Yes, on Windows | ❌ No |

MBS( "DynaPDF.Print"; PDF { ; PrinterName; TempPath; DocName; PrintFlags; MarginLeft; MarginTop; MarginRight; MarginBottom; ShowDialog; MaxRes } ) 

**MBS**( **"DynaPDF.Print";** /\* Prints the PDF file that is currently in memory. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$PrinterName**; /\* Optional; Printer name.  
Ignored if dialog is shown.  
See [Printer.PrinterNames](PrinterPrinterNames.md) functiomn for printer names.  
  
If empty, we take it from printer settings.e.g. "myPrinter" \*/   
**$TempPath**; /\* Optional; The path to temporary folder.  
Can be empty for default folder.e.g. "" \*/   
**$DocName**; /\* Optional; The name of the print job.e.g. "My PDF Print" \*/   
**$PrintFlags**; /\* Optional; The flags for printing.   
Can be a combination of Default, 1bit, Color, AutoRotateAndCenter, PrintAsImage or ShrinkToPrintArea.  
Can be just the text name of an option or the sum of the numbers.e.g. "Color" \*/   
**$MarginLeft**; /\* Optional; The margin for the left for the page.  
Pass zero if you don't need an extra margin. \*/   
**$MarginTop**; /\* Optional; The margin for the top for the page. \*/   
**$MarginRight**; /\* Optional; The margin for the right for the page. \*/   
**$MarginBottom**; /\* Optional; The margin for the bottom for the page. \*/   
**$ShowDialog**; /\* Optional; Whether to show dialog.  
Default is 0 as we want no dialog.   
Pass 1 to show a dialog here.e.g. 0 \*/   
**$MaxRes**) /\* Optional; The maximum resolution to use.  
If value is zero or empty, we use default print resolution.e.g. 300 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| PrinterName | Printer name.   Ignored if dialog is shown.   See [Printer.PrinterNames](PrinterPrinterNames.md) functiomn for printer names.      If empty, we take it from printer settings. | "myPrinter" | Optional |
| TempPath | The path to temporary folder.   Can be empty for default folder. | "" | Optional |
| DocName | The name of the print job. | "My PDF Print" | Optional |
| PrintFlags | The flags for printing.    Can be a combination of Default, 1bit, Color, AutoRotateAndCenter, PrintAsImage or ShrinkToPrintArea.   Can be just the text name of an option or the sum of the numbers. | "Color" | Optional |
| MarginLeft | The margin for the left for the page.   Pass zero if you don't need an extra margin. |  | Optional |
| MarginTop | The margin for the top for the page. |  | Optional |
| MarginRight | The margin for the right for the page. |  | Optional |
| MarginBottom | The margin for the bottom for the page. |  | Optional |
| ShowDialog | Whether to show dialog.   Default is 0 as we want no dialog.    Pass 1 to show a dialog here. | 0 | Optional      Added in version **6.5**. |
| MaxRes | The maximum resolution to use.   If value is zero or empty, we use default print resolution. | 300 | Optional |

### Result

Returns OK or error.

### Description

Prints the PDF file that is currently in memory.   
At time of publication the function is implemented on Windows only and pages are printed as image.   
The parameter DocName is optional but should be set if possible. The document name is set to "out" if no name is provided.   
  
Output color format   
It is possible to determine which color formats a printer supports as input, but it is not possible to determine whether a printer outputs black &amp; white, gray shades, or color. The default should be set to gray or 1 bit but the user should be able to configure the color format.   
  
Maximum output resolution   
The maximum output resolution is 600 DPI to restrict the memory usage and to reduce the amount of data that must be send to the printer.   
  
| Name | Value | Description |
|---|---|---|
| Default | 0 | Gray printing |
| 1Bit | 1 | B/W printing. Recommended for b&amp;w printers |
| Color | 2 | Color printing |
| AutoRotateAndCenter | 4 | Rotate and center pages if necessary |
| PrintAsImage | 8 | Default on Windows |
| ShrinkToPrintArea | 16 | Useful if a page contains no margins |
| PrintPageAsIs | 256 | Print page as is, ignoring paper size. |

  
Please use [PDFKit.Print](PDFKitPrint.md) for macOS.   
  
If you only want to print a selection of pages, please only import those pages via [DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md) function. Or use [DynaPDF.DeletePage](DynaPDFDeletePage.md) to remove the pages you don't want to print.  
  
Requires DynaPDF Pro license.   
For all image operation, it is recommended to initialize color management with [DynaPDF.InitColorManagement](DynaPDFInitColorManagement.md) function.  
See also [Print](https://www.monkeybreadsoftware.com/DynaPDF-Manual/PrintPDFFile.shtml) function in DynaPDF manual.

### Examples

Prints a PDF to printer

 MBS ( "DynaPDF.Print"; $PDF ; "MyPrinter")  
Import PDF and print:

 #Initialize DynaPDF if needed   
If \[MBS ("[DynaPDF.IsInitialized](DynaPDFIsInitialized.md)") ≠ 1\]  
 Perform Script \[“InitDynaPDF”\]  
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](DynaPDFOpenPDFFromContainer.md)"; $pdf ; Print PDFs::InputPDF )\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)"; $pdf ; $destpage )\]  
\#Print   
Set Variable \[$r ; Value:MBS ("DynaPDF.Print"; $pdf ; Print PDFs::Printer Name; 2+4+16)\]  
\#Cleanup   
Set Variable \[$r ; Value:MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf )\]  
Print with dialog:

 MBS ("DynaPDF.Print";   
$pdf ;   
""; // printer name   
""; // temp path  
""; // job name  
"Default"; // options  
""; // margins  
"";   
"";   
"";   
1) // show dialog  
Print with portrait:

 Set Variable \[ $Flags ; Value: 16 \]   
Set Variable \[ $ShowDialog ; Value: 0 \]   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.Print.SetSetting](DynaPDFPrintSetSetting.md)"; "PaperSize"; 9) // A4 210 x 297 mm \]   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.Print.SetSetting](DynaPDFPrintSetSetting.md)"; "Orientation"; 1) // Portrait \]   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.Print.SetSetting](DynaPDFPrintSetSetting.md)"; "PrinterName"; "Microsoft Print to PDF") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.Print"; $pdf ; ""; ""; ""; $Flags ; ""; ""; ""; ""; $ShowDialog ) \]  
### See also

- [DynaPDF.List](DynaPDFList.md)
- [DynaPDF.Print.FormNames](DynaPDFPrintFormNames.md)
- [DynaPDF.Print.GetDevMode](DynaPDFPrintGetDevMode.md)
- [DynaPDF.Print.GetDevNames](DynaPDFPrintGetDevNames.md)
- [DynaPDF.Print.GetSetting](DynaPDFPrintGetSetting.md)
- [DynaPDF.Print.SetDevMode](DynaPDFPrintSetDevMode.md)
- [DynaPDF.Print.SetDevNames](DynaPDFPrintSetDevNames.md)
- [DynaPDF.Print.SetSetting](DynaPDFPrintSetSetting.md)
- [PDFKit.Print](PDFKitPrint.md)
- [Printer.PrinterNames](PrinterPrinterNames.md)

### Release notes

- **Version 15.1**
    - Added useProgressDialog flag for [DynaPDF.Print](https://www.mbsplugins.eu/DynaPDFPrint.shtml) to tell the plugin to update the progress dialog while printing.
- **Version 11.5**
    - Added [DynaPDF.Print.FormNames](https://www.mbsplugins.eu/DynaPDFPrintFormNames.shtml) function to get list of form names for printer on Windows.
    - Improved [DynaPDF.Print.SetSetting](https://www.mbsplugins.eu/DynaPDFPrintSetSetting.shtml) to make it work better.
- **Version 11.4**
    - Added [DynaPDF.Print.GetSetting](https://www.mbsplugins.eu/DynaPDFPrintGetSetting.shtml) and [DynaPDF.Print.SetSetting](https://www.mbsplugins.eu/DynaPDFPrintSetSetting.shtml) functions.
    - Improved threading for [DynaPDF.Print](https://www.mbsplugins.eu/DynaPDFPrint.shtml) functions to store settings per thread to avoid potential threading issues.
- **Version 10.5**
    - Changed [DynaPDF.Print](https://www.mbsplugins.eu/DynaPDFPrint.shtml) to tell printer dialog that we are okay with collate and copies, so that option may get enabled on supporting printer drivers.
- **Version 9.1**
    - Added MaxRes Parameter for [DynaPDF.Print](http://www.mbsplugins.eu/DynaPDFPrint.shtml) function.
- **Version 8.4**
    - Changed [DynaPDF.Print](http://www.mbsplugins.eu/DynaPDFPrint.shtml) to get default printer, if you pass empty printer name.
    - Improved [DynaPDF.Print](http://www.mbsplugins.eu/DynaPDFPrint.shtml) to use the device mode set with [DynaPDF.Print.SetDevMode](http://www.mbsplugins.eu/DynaPDFPrintSetDevMode.shtml) even if no dialog is used.
- **Version 8.2**
    - Added checks to [DynaPDF.Optimize](http://www.mbsplugins.eu/DynaPDFOptimize.shtml), [DynaPDF.Print](http://www.mbsplugins.eu/DynaPDFPrint.shtml) and [DynaPDF.Save](http://www.mbsplugins.eu/DynaPDFSave.shtml) to complain if no pages are in document.
- **Version 8.0**
    - Fixed bugs with [DynaPDF.Print](http://www.mbsplugins.eu/DynaPDFPrint.shtml) and scaling pages for some printers.
- **Version 7.0**
    - Added [DynaPDF.Print.GetDevMode](http://www.mbsplugins.eu/DynaPDFPrintGetDevMode.shtml), [DynaPDF.Print.GetDevNames](http://www.mbsplugins.eu/DynaPDFPrintGetDevNames.shtml), [DynaPDF.Print.SetDevMode](http://www.mbsplugins.eu/DynaPDFPrintSetDevMode.shtml) and [DynaPDF.Print.SetDevNames](http://www.mbsplugins.eu/DynaPDFPrintSetDevNames.shtml).

### Example Databases

- [DynaPDF/Print PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Print%20PDF.shtml#2ScriptAnchor_)

### Blog Entries

- [MBS @ FMTraining.TV - Printing in FileMaker with the MonkeyBread Plug-in](https://www.mbsplugins.de/archive/2024-04-17/MBS_@_FMTrainingTV_-_Printing_/monkeybreadsoftware_blog_filemaker)
- [Top 10 from the MBS Plugin in 2022](https://www.mbsplugins.de/archive/2022-12-29/Top_10_from_the_MBS_Plugin_in_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 12.3](https://www.mbsplugins.de/archive/2022-07-19/MBS_FileMaker_Plugin_123/monkeybreadsoftware_blog_filemaker)
- [New error log functions for FileMaker](https://www.mbsplugins.de/archive/2022-06-23/New_error_log_functions_for_Fi/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)
- [New in MBS FileMaker Plugin 10.5](https://www.mbsplugins.de/archive/2020-11-23/New_in_MBS_FileMaker_Plugin_10/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.5 - More than 6400 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-11-17/MBS_FileMaker_Plugin_105_-_Mor/monkeybreadsoftware_blog_filemaker)
- [Combine MBS functions to automate processes in FileMaker](https://www.mbsplugins.de/archive/2019-04-11/Combine_MBS_functions_to_autom/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 5.4 for OS X/Windows](https://www.mbsplugins.de/archive/2015-11-24/MBS_FileMaker_Plugin_54_for_OS/monkeybreadsoftware_blog_filemaker)
- [PDF Printing in FileMaker on Windows without PDF Reader](https://www.mbsplugins.de/archive/2015-10-21/PDF_Printing_in_FileMaker_on_W/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2021, Seite 29](https://filemaker-magazin.de/neuigkeit/4158-Appetithappen-FMM_202105)
- [Ausgabe 6/2017, Seite 26](https://filemaker-magazin.de/neuigkeit/3967-Appetithappen-FMM_201706)

This function is free to use.

Created 21st October 2015 , last changed 3th April 2024

  
[DynaPDF.PlaceTemplateEx](DynaPDFPlaceTemplateEx.md) - [DynaPDF.Print.FormNames](DynaPDFPrintFormNames.md)

[HTML Version](DynaPDFPrint.shtml)