DynaPDF.EnableImageCache
------------------------

Creates an image cache that is used when rendering PDF pages.

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

MBS( "DynaPDF.EnableImageCache"; PDF; MaxImageCount; Size ) 

**MBS**( **"DynaPDF.EnableImageCache";** /\* Creates an image cache that is used when rendering PDF pages. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$MaxImageCount**; /\* Maximum number of images to be cached. \*/   
**$Size**) /\* Maximum cache size in bytes. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| MaxImageCount | Maximum number of images to be cached. |  |
| Size | Maximum cache size in bytes. |  |

### Result

Returns OK or error.

### Description

Creates an image cache that is used when rendering PDF pages.   
The maximum number of images and the maximum cache size can be set independently of each other.  
Caching can speed up rendering dramatically but caching can also slow down rendering if too many images are in the cache. Therefore, the maximum number of images must be restricted. The value should be between 256 and 1024 but not much higher.  
The optimal cache size depends on the number of pages and whether the app is 32 or 64 bit. The cache size can be large, e.g. up to 1 GB on 32 bit or 2 GB on 64 bit systems, if a document contains only a few pages. Images are cached only if the system contains enough memory.  
The size of the image cache should be around 30% of the entire cache size for rendered images. If the full cache size is 1 GB, for example, then around 300 MB should be used for the image cache. Keep all caches dynamic depending on the currently available memory.  
The cache size is automatically reduced if the system has not sufficient memory.  
The cache is always cleared when the PDF file in memory was closed or when FreePDF() was called. In order to disable or delete the cache set MaxImageCount or Size to zero.  
See also [EnableImageCache](https://www.monkeybreadsoftware.com/DynaPDF-Manual/EnableImageCache.shtml) function in DynaPDF manual.

### Examples

Cache up to 512 images with maximum of 1 GB in total:

 Set Variable \[ $r ; Value: MBS ("DynaPDF.EnableImageCache"; $pdf ; 512; 1024 \* 1024 \* 1024 /\* 1 GB \*/ ) \]  
### See also

- [DynaPDF.New](DynaPDFNew.md)

### Release notes

- **Version 14.3**
    - Added [DynaPDF.SetLineAnnotPoints](https://www.mbsplugins.eu/DynaPDFSetLineAnnotPoints.shtml) and [DynaPDF.EnableImageCache](https://www.mbsplugins.eu/DynaPDFEnableImageCache.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin 14.3 News](https://www.mbsplugins.de/archive/2024-07-17/MBS_FileMaker_Plugin_143_News/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.3pr3](https://www.mbsplugins.de/archive/2024-06-14/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 14th June 2024 , last changed 9th July 2024

  
[DynaPDF.EnableEncryption](DynaPDFEnableEncryption.md) - [DynaPDF.EndLayer](DynaPDFEndLayer.md)

[HTML Version](DynaPDFEnableImageCache.shtml)