DynaPDF.SetCompressionFilter
----------------------------

The function sets the compression filter which is used to compress images.

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

MBS( "DynaPDF.SetCompressionFilter"; PDF; Filter ) 

**MBS**( **"DynaPDF.SetCompressionFilter";** /\* The function sets the compression filter which is used to compress images. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Filter**) /\* The compression flter to use: Flate, JPEG, JP2K, CCITT3, CCITT4, LZW, LZWBW, FlateBW, JBIG2.e.g. "JPEG" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Filter | The compression flter to use: Flate, JPEG, JP2K, CCITT3, CCITT4, LZW, LZWBW, FlateBW, JBIG2. | "JPEG" |

### Result

Returns OK on success.

### Description

The function sets the compression filter which is used to compress images.   
1 bit and 4 bit images are always compressed with Flate independent of the current compression filter. The filters are described in detail at InsertImage in DynaPDF help file.  
See also [SetCompressionFilter](https://www.monkeybreadsoftware.com/DynaPDF-Manual/SetCompressionFilter.shtml) function in DynaPDF manual.

### Examples

Compress images with 75% JPEG compression:

 MBS ( "DynaPDF.SetCompressionFilter"; $PDF ; "jpeg" )  
MBS ( "[DynaPDF.SetJPEGQuality](DynaPDFSetJPEGQuality.md)"; $PDF ; 75 )  
Disable compression for best results:

 MBS ( "DynaPDF.SetCompressionFilter"; $PDF ; "flate" )  
### See also

- [DynaPDF.ClipPath](DynaPDFClipPath.md)
- [DynaPDF.DrawCircle](DynaPDFDrawCircle.md)
- [DynaPDF.GetCompressionFilter](DynaPDFGetCompressionFilter.md)
- [DynaPDF.GetCompressionLevel](DynaPDFGetCompressionLevel.md)
- [DynaPDF.InsertImage](DynaPDFInsertImage.md)
- [DynaPDF.InsertImageFile](DynaPDFInsertImageFile.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetCompressionLevel](DynaPDFSetCompressionLevel.md)
- [DynaPDF.SetJPEGQuality](DynaPDFSetJPEGQuality.md)
- [DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md)

### Example Databases

- [DynaPDF/Picture to PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Picture%20to%20PDF.shtml#5ScriptAnchor_)
- [DynaPDF/Place Template](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Place%20Template.shtml#2ScriptAnchor_)
- [DynaPDF/Scan with WIA to PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Scan%20with%20WIA%20to%20PDF.shtml#24ScriptAnchor_)
- [DynaPDF/Watermark pages](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Watermark%20pages.shtml#2ScriptAnchor_)

### Blog Entries

- [Page Layouting in DynaPDF](https://www.mbsplugins.de/archive/2024-04-05/Page_Layouting_in_DynaPDF/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th August 2014 , last changed 31st August 2018

  
[DynaPDF.SetColorSpace](DynaPDFSetColorSpace.md) - [DynaPDF.SetCompressionLevel](DynaPDFSetCompressionLevel.md)

[HTML Version](DynaPDFSetCompressionFilter.shtml)