# Windows PDF Functions

**URL:** <https://the.fmsoup.org/t/windows-pdf-functions/3504>\
**Category:** MBS Plugins\
**Tags:** scripting, pdf, plugin, windows, mbs\
**Created:** [April 15, 2023, 8:45am UTC](https://the.fmsoup.org/t/windows-pdf-functions/3504 "2023-04-15T08:45:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [April 15, 2023, 8:45am UTC](https://the.fmsoup.org/t/windows-pdf-functions/3504/1 "2023-04-15T08:45:11Z")

</div>

Since Microsoft added some PDF functions to their frameworks in Windows 10, we can now implement this to our MBS FileMaker Plugin. That got possible since we dropped Windows 7 and require newer functions for component management in Windows 8. For [MBS FileMaker Plugin](https://www.monkeybreadsoftware.com/filemaker/) 13.2, we add the new functions for you to try out:

![](https://www.mbsplugins.de/image/FMWindowsPDF.png)

[WinPDF.GeneratePreview](https://www.mbsplugins.eu/WinPDFGeneratePreview.shtml)  
Adds preview to an existing PDF container.  
[WinPDF.IsPasswordProtected](https://www.mbsplugins.eu/WinPDFIsPasswordProtected.shtml)  
Whether this document is password-protected.  
[WinPDF.LoadContainer](https://www.mbsplugins.eu/WinPDFLoadContainer.shtml)  
Loads a PDF document from data in container.  
[WinPDF.LoadFile](https://www.mbsplugins.eu/WinPDFLoadFile.shtml)  
Loads a PDF document from file synchronously.  
[WinPDF.PageBox](https://www.mbsplugins.eu/WinPDFPageBox.shtml)  
Queries page dimensions.  
[WinPDF.PageCount](https://www.mbsplugins.eu/WinPDFPageCount.shtml)  
Gets the number of pages in the Portable Document Format (PDF) document.  
[WinPDF.PageHeight](https://www.mbsplugins.eu/WinPDFPageHeight.shtml)  
Queries page height.  
[WinPDF.PageImage](https://www.mbsplugins.eu/WinPDFPageImage.shtml)  
Renders a page to an image.  
[WinPDF.PageImageAtSize](https://www.mbsplugins.eu/WinPDFPageImageAtSize.shtml)  
Renders a page to an image.  
[WinPDF.PagePreferredZoom](https://www.mbsplugins.eu/WinPDFPagePreferredZoom.shtml)  
Gets the Portable Document Format (PDF) page's preferred magnification factor.  
[WinPDF.PageRotation](https://www.mbsplugins.eu/WinPDFPageRotation.shtml)  
Queries rotation for a page.  
[WinPDF.PageWidth](https://www.mbsplugins.eu/WinPDFPageWidth.shtml)  
Queries page width.  
[WinPDF.Release](https://www.mbsplugins.eu/WinPDFRelease.shtml)  
Releases an object reference.

The key feature is to open PDF documents and render preview pictures for individual pages. The functions do not things like merge and split, form controls or creating of new PDF documents. For that, please use our [DynaPDF](https://www.mbsplugins.eu/component_DynaPDF.shtml) functions.

The [WinPDF.LoadContainer](https://www.mbsplugins.eu/WinPDFLoadContainer.shtml) function can load a PDF from a container while [WinPDF.LoadFile](https://www.mbsplugins.eu/WinPDFLoadFile.shtml) takes a native file path. The loading is synchronously, so this may take a second for bigger documents.

Once the document is loaded, you can query page count with [WinPDF.PageCount](https://www.mbsplugins.eu/WinPDFPageCount.shtml) functions. Then you can loop over the pages and [query page size](https://www.mbsplugins.eu/WinPDFPageHeight.shtml) for each page, the [preferred zoom level](https://www.mbsplugins.eu/WinPDFPagePreferredZoom.shtml)or the [rotation](https://www.mbsplugins.eu/WinPDFPageRotation.shtml). Dimensions can be queried for [all page boxes](https://www.mbsplugins.eu/WinPDFPageBox.shtml):

- Media Box, the size of the paper
- Art Box, the size of the content, which should not be covered later.
- Bleed Box, the area to draw to, usually bigger than trim box.
- Trim Box, where to cut the paper after printing.
- Crop Box, the area to show or print.

Most of them are optional we usually just use Media Box to show whole page. Or on processing the pages, we may use crop box (if exists) to only show the cropped part.

You can render the page to a picture. The [WinPDF.PageImage](https://www.mbsplugins.eu/WinPDFPageImage.shtml) function returns a container with picture data encoded in either JPEG, PNG, TIFF or BMP. This can be configured with the parameters to request a specific image type or DPI level. If you need a specific width or height, you can use [WinPDF.PageImageAtSize](https://www.mbsplugins.eu/WinPDFPageImageAtSize.shtml) function instead.

Finally we have a function called [WinPDF.GeneratePreview](https://www.mbsplugins.eu/WinPDFGeneratePreview.shtml) to add a preview to a PDF container after importing it. The function uses PDFKit on macOS and Windows PDF functions on Windows and is an alias for [PDFKit.GeneratePreview](https://www.mbsplugins.eu/PDFKitGeneratePreview.shtml) function. If you need something cross platform (with Linux), you can use [DynaPDF.GeneratePreview](https://www.mbsplugins.eu/DynaPDFGeneratePreview.shtml) function and enjoy better rendering.

Another thing we could make it a comparison of the preview graphics and check how much Microsoft implemented on the more special cases. Like checking for gradients, spot colors, CMYK colors and embedded image formats. [PDFKit](https://www.mbsplugins.eu/component_PDFKit.shtml) functions on macOS also has a few limits there, so if you need full coverage, you may want to check out [DynaPDF](https://www.mbsplugins.eu/component_DynaPDF.shtml) functions.

Please don't hesitate to contact us if you have questions.
