DynaPDF Manual - Page 772

Previous Page 771   Index   Next Page 773

Function Reference
Page 772 of 818
current clipping path. The settings of the current line width and stroke
color are used to paint the path.
dmFillStrokeClip
Tread the glyph outlines as path to be stroked and filled and add this path
to the current clipping path. The settings of the current line width, fill
color and stroke color are used to paint the path.
dmClipping
Tread the glyph outlines as path and add this path to the current clipping
path.
How to use text as clipping path?
As mentioned earlier the usage of text as clipping path is not the same as a normal clipping path.
The following example shows how a text can be used for clipping:
Example (C++):
#include "dynapdf.h"
using namespace DynaPDF;
// First we declare an error callback function.
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
{
printf("%s\n", ErrMessage);
return 0; // We ignore non-fatal errors
}
int main(int argc, char* argv[])
{
void* pdf = pdfNewPDF();
if (!pdf) return 2; // Out of memory?
pdfSetOnErrorProc(pdf, NULL, PDFError);
// The document info entries are changed by the function if set
pdfSetDocInfo(pdf, diSubject, "Text as clipping path");
pdfSetDocInfo(pdf, diCreator, "C++ example test project");
pdfSetDocInfo(pdf, diTitle, "Text as clipping path");
pdfSetPageCoords(pdf, pcTopDown);
pdfCreateNewPDF(pdf, "c:/cppout.pdf");
pdfAppend(pdf);
pdfSetFont(pdf, "Bookman Old Style", fsBold, 80, true, cp1252);
// We want to draw an axial shading into the clipping path
SI32 sh = pdfCreateAxialShading(pdf, 0, 50, 0, 130, 1, PDF_BLUE,
PDF_YELLOW, false, false);
// Do not forget to save the graphics state
pdfSaveGraphicState(pdf);
pdfSetTextDrawMode(pdf, dmClipping); // Use the text as clipping path
 

Previous topic: SetTextDrawMode

Next topic: SetTextFieldValue, Field format


Start Chat