PDFKit.GeneratePreview
----------------------

Adds preview to an existing PDF container.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [PDFKit](component_PDFKit.md) | [7.5](newinversion75.md) | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes, on macOS and Windows | ✅ Yes |

MBS( "PDFKit.GeneratePreview"; Container ) 

**MBS**( **"PDFKit.GeneratePreview";** /\* Adds preview to an existing PDF container. \*/  
**$Container**) /\* A media value containing PDF data. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Container | A media value containing PDF data. |  |

### Result

Returns updated container value or error.

### Description

Adds preview to an existing PDF container.  
For Windows or Linux, please use [DynaPDF.GeneratePreview](DynaPDFGeneratePreview.md).  
  
See [Plugin.SetPreviewSize](PluginSetPreviewSize.md) for setting resolution of previews.  
If called on Windows, will internally run [WinPDF.GeneratePreview](WinPDFGeneratePreview.md) function.  
### Examples

Generate preview:

 Set Field \[ Merge PDFs::FinalPDF ; MBS ("PDFKit.GeneratePreview"; Merge PDFs::InputPDF ) \]  
Add a preview to PDF container if needed:

 # get a PDF somewhere   
Set Variable \[ $PDF ; Value: MBS ( "[Files.ReadFile](FilesReadFile.md)"; "C:\\Users\\Christian\\Desktop\\test.pdf"; "auto") \]   
\# Does have PDF and no image?   
Set Variable \[ $types ; Value: MBS ( "[Container.GetTypes](ContainerGetTypes.md)"; $PDF ) \]   
\# PDF included?   
If \[ Position ( $types ; "PDF " ; 1 ; 1 ) &gt; 0 \]   
 # Image preview missing?  
 If \[ Position ( $types ; "JPEG" ; 1 ; 1 ) &lt; 1 and Position ( $types ; "PNGf" ; 1 ; 1 ) &lt; 1 \]   
 # Use DynaPDF if initialized, we can use it  
 If \[ MBS ( "[DynaPDF.IsInitialized](DynaPDFIsInitialized.md)" ) \]   
 Set Variable \[ $PDF2 ; Value: MBS ( "[DynaPDF.GeneratePreview](DynaPDFGeneratePreview.md)"; $PDF ) \]   
 If \[ MBS ("IsError") = 0 \]   
 # Success, so use the new PDF  
 Set Variable \[ $PDF ; Value: $PDF2 \]   
 End If  
 Else If \[ MBS ( "IsMacOSX" ) = 1 \]   
 # On Mac use PDFKit  
 Set Variable \[ $PDF2 ; Value: MBS ( "PDFKit.GeneratePreview"; $PDF ) \]   
 If \[ MBS ("IsError") = 0 \]   
 # Success, so use the new PDF  
 Set Variable \[ $PDF ; Value: $PDF2 \]   
 End If  
 End If  
 End If  
End If  
\# Store PDF with preview   
Set Field \[ test::Image ; $PDF \]  
### See also

- [Container.GetType](ContainerGetType.md)
- [Container.GetTypes](ContainerGetTypes.md)
- [DynaPDF.GeneratePreview](DynaPDFGeneratePreview.md)
- [DynaPDF.IsInitialized](DynaPDFIsInitialized.md)
- [Files.ReadFile](FilesReadFile.md)
- [IsError](IsError.md)
- [Plugin.SetPreviewSize](PluginSetPreviewSize.md)
- [WinPDF.GeneratePreview](WinPDFGeneratePreview.md)

### Release notes

- **Version 13.2**
    - Implemented [PDFKit.GeneratePreview](https://www.mbsplugins.eu/PDFKitGeneratePreview.shtml) for Windows by using [WinPDF](https://www.mbsplugins.eu/component_WinPDF.shtml) functions.
- **Version 11.2**
    - Improved memory usage of [Container.ReadImage](https://www.mbsplugins.eu/ContainerReadImage.shtml), [PDFKit.GeneratePreview](https://www.mbsplugins.eu/PDFKitGeneratePreview.shtml) and [PDFKit.GetPDFPageImage](https://www.mbsplugins.eu/PDFKitGetPDFPageImage.shtml) functions, especially for server.
- **Version 7.5**
    - Added [PDFKit.GeneratePreview](http://www.mbsplugins.eu/PDFKitGeneratePreview.shtml).

### Blog Entries

- [Windows PDF Functions](https://www.mbsplugins.de/archive/2023-04-11/Windows_PDF_Functions/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.2pr1](https://www.mbsplugins.de/archive/2023-04-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Render pictures from PDF](https://www.mbsplugins.de/archive/2021-06-27/Render_pictures_from_PDF/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.2pr4](https://www.mbsplugins.de/archive/2021-04-21/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.5pr3](https://www.mbsplugins.de/archive/2017-10-23/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 17th October 2017 , last changed 3th May 2023

  
[PDFKit.CombineRef](PDFKitCombineRef.md) - [PDFKit.GetCurrentFilter](PDFKitGetCurrentFilter.md)

[HTML Version](PDFKitGeneratePreview.shtml)