How to Manipulate Primitives to Clip Drawing Objects
Knowledge Base :: PDF Creator Pilot 4 Knowledge Base

See Also
Collapse All

You can manipulate primitives to clip pictures:

1. Create a path that will clip a future picture. Be sure that the path is closed.

Delphi :

PDF.DrawEllipse(50, 100, PDF.PageWidth - 50, PDF.PageHeight - 50);
PDF.ClosePath;

Visual Basic or Visual Basic Script :

PDF.DrawEllipse 50, 100, PDF.PageWidth - 50, PDF.PageHeight - 50
PDF.ClosePath 

C/C++ :

PDF->PDFPAGE_Ellipse(50, 100, PDF->PageWidth - 50, PDF->PageHeight - 50);
PDF->ClosePath();

C# :

PDF.PDFPAGE_Ellipse(50, 100, PDF.PageWidth - 50, PDF.PageHeight - 50);
PDF.ClosePath();

2. Set the current path as the clipping path.

Delphi :

PDF.Clip;

Visual Basic or Visual Basic Script :

PDF.Clip 

C/C++ :

PDF->Clip();

C# :

PDF.Clip();

3. Draw other objects or pictures using a new path.

Delphi :

PDF.ResetPath;
PDF.SetColor(0, 0, 0.5 , 0);
PDF.DrawEllipse(0, 0, PDF.PageWidth, PDF.PageHeight); { Ellipse filled in page }

Visual Basic or Visual Basic Script :

PDF.ResetPath 
PDF.SetColor 0, 0, 0.5 , 0
PDF.DrawEllipse 0, 0, PDF.PageWidth, PDF.PageHeight 'Ellipse filled in page

C/C++ :

PDF.ResetPath();
PDF.SetColor(0, 0, 0.5f, 0);
PDF.DrawEllipse(0, 0, PDF->PageWidth, PDF.->PageHeight); // Ellipse filled in page

C# :

PDF.ResetPath();
PDF.SetColor(0, 0, 0.5f, 0);
PDF.DrawEllipse(0, 0, PDF.PageWidth, PDF.PageHeight); // Ellipse filled in page

4. Stroke your picture and it will be clipped by the clipping path.

Delphi :

PDF.FillAndStroke;

Visual Basic or Visual Basic Script :

PDF.FillAndStroke 

C/C++ :

PDF->FillAndStroke();

C# :

PDF.FillAndStroke();

For more details see ClipAlternateClip, ClosePath, ResetPath.

Note: You cannot reset the clipping path. Use SaveGraphicsState and RestoreGraphicsState to save and restore the graphical state and clipping region.

See Also

Reference