DynaPDF.ClipPath
----------------

This function marks the current path as clipping path.

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

MBS( "DynaPDF.ClipPath"; PDF; ClipMode; FillMode ) 

**MBS**( **"DynaPDF.ClipPath";** /\* This function marks the current path as clipping path. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$ClipMode**; /\* The clipping mode. Can be EvenOdd for using the Even-Odd rule or winding for using the nonzero Winding Number rule.e.g. "winding" \*/   
**$FillMode**) /\* Fill mode. Can be FillNoClose, StrokeNoClose, FillStrokeNoClose, Fill, Stroke, FillStroke, FillEvOdd, FillStrokeEvOdd, FillEvOddNoClose, FillStrokeEvOddNoClose, NoFill or Close.e.g. "fill" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| ClipMode | The clipping mode. Can be EvenOdd for using the Even-Odd rule or winding for using the nonzero Winding Number rule. | "winding" |
| FillMode | Fill mode. Can be FillNoClose, StrokeNoClose, FillStrokeNoClose, Fill, Stroke, FillStroke, FillEvOdd, FillStrokeEvOdd, FillEvOddNoClose, FillStrokeEvOddNoClose, NoFill or Close. | "fill" |

### Result

Returns OK or error.

### Description

This function marks the current path as clipping path.   
The function must be called after a closable path was created. A path that consists of a [DynaPDF.MoveTo](DynaPDFMoveTo.md) and [DynaPDF.LineTo](DynaPDFLineTo.md) only call cannot be closed!  
A clipping path can also be filled, stroked, or both in one pass. However, the combination of a clipping path operator with a path painting operator is seldom used and not supported in all PDF viewers. To avoid unnecessary problems a path should always be clipped and painted in two separate steps, also if this causes some unnecessary overhead.  
Once the clipping was created and activated with DynaPDF.ClipPath you can draw arbitrary contents into it, such as images, text, or vector graphics.  
A clipping path is part of the current graphics state. The only way to deactivate a clipping path is to restore the graphics state with [DynaPDF.RestoreGraphicState](DynaPDFRestoreGraphicState.md). This assumes that it was saved with [DynaPDF.SaveGraphicState](DynaPDFSaveGraphicState.md) before the clipping path was created.  
Note that it is not possible to extend or widen an active clipping path. It is only possible to intersect it with a new one. The intersection of two clipping paths is never larger than the initial clipping path.  
Remarks:  
Text objects are handled separately in PDF for use as clipping path. See [DynaPDF.SetTextDrawMode](DynaPDFSetTextDrawMode.md) for further information.  
See also [ClipPath](https://www.monkeybreadsoftware.com/DynaPDF-Manual/ClipPath.shtml) function in DynaPDF manual.

### Examples

Clip image to circle:

 # 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)") \]   
\# Add image on page   
Set Variable \[ $destPage ; Value: 1 \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.AppendPage](DynaPDFAppendPage.md)"; $pdf ) \]   
\# no recompression if possible! But if needed, we use JPEG 90%   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md)"; $pdf ; 0) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetJPEGQuality](DynaPDFSetJPEGQuality.md)"; $pdf ; 90) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetCompressionFilter](DynaPDFSetCompressionFilter.md)"; $pdf ; "jpeg") \]   
\# Save old state to restore later   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.SaveGraphicState](DynaPDFSaveGraphicState.md)"; $pdf ) \]   
\# Draw circle for clipping   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.DrawCircle](DynaPDFDrawCircle.md)"; $pdf ; 260; 220; 100; "nofill" ) \]   
Set Variable \[ $r ; Value: MBS ( "DynaPDF.ClipPath"; $pdf ; "Winding"; "fill" ) \]   
\# Draw clipped image   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.InsertImage](DynaPDFInsertImage.md)"; $pdf ; Merge PDFs::InputImage ; 100; 100; 320; 200) \]   
\# restore graphics static to get unclipped drawing   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.RestoreGraphicState](DynaPDFRestoreGraphicState.md)"; $pdf ) \]   
\# Close page and store PDF in container   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf ) \]   
Set Field \[ Merge PDFs::FinalPDF ; MBS ("[DynaPDF.Save](DynaPDFSave.md)"; $pdf ; "Merged.pdf") \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf ) \]  
### See also

- [DynaPDF.ClosePath](DynaPDFClosePath.md)
- [DynaPDF.LineTo](DynaPDFLineTo.md)
- [DynaPDF.MoveTo](DynaPDFMoveTo.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.RestoreGraphicState](DynaPDFRestoreGraphicState.md)
- [DynaPDF.RoundRectEx](DynaPDFRoundRectEx.md)
- [DynaPDF.SetCompressionFilter](DynaPDFSetCompressionFilter.md)
- [DynaPDF.SetJPEGQuality](DynaPDFSetJPEGQuality.md)
- [DynaPDF.SetSaveNewImageFormat](DynaPDFSetSaveNewImageFormat.md)
- [DynaPDF.SetTextDrawMode](DynaPDFSetTextDrawMode.md)

### Example Databases

- [DynaPDF/Page Layouting](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Page%20Layouting.shtml#2ScriptAnchor_)
- [DynaPDF/Signature Appearance](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Signature%20Appearance.shtml#1ScriptAnchor_)

### 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 17th January 2019

  
[DynaPDF.ClearLicense](DynaPDFClearLicense.md) - [DynaPDF.CloseImportFile](DynaPDFCloseImportFile.md)

[HTML Version](DynaPDFClipPath.shtml)