PoDoFo 0.9.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PoDoFo::PdfPainter Class Reference

#include <PdfPainter.h>

Inheritance diagram for PoDoFo::PdfPainter:
PoDoFo::PdfPainterMM

Public Member Functions

 PdfPainter ()
 
void SetPage (PdfCanvas *pPage)
 
PdfCanvasGetPage () const
 
PdfStreamGetCanvas () const
 
void FinishPage ()
 
void SetStrokingGray (double g)
 
void SetGray (double g)
 
void SetStrokingColor (double r, double g, double b)
 
void SetColor (double r, double g, double b)
 
void SetStrokingColorCMYK (double c, double m, double y, double k)
 
void SetColorCMYK (double c, double m, double y, double k)
 
void SetStrokingShadingPattern (const PdfShadingPattern &rPattern)
 
void SetShadingPattern (const PdfShadingPattern &rPattern)
 
void SetStrokingTilingPattern (const PdfTilingPattern &rPattern)
 
void SetStrokingTilingPattern (const std::string &rPatternName)
 
void SetTilingPattern (const PdfTilingPattern &rPattern)
 
void SetTilingPattern (const std::string &rPatternName)
 
void SetStrokingColor (const PdfColor &rColor)
 
void SetColor (const PdfColor &rColor)
 
void SetStrokeWidth (double dWidth)
 
void SetStrokeStyle (EPdfStrokeStyle eStyle, const char *pszCustom=NULL, bool inverted=false, double scale=1.0, bool subtractJoinCap=false)
 
void SetLineCapStyle (EPdfLineCapStyle eCapStyle)
 
void SetLineJoinStyle (EPdfLineJoinStyle eJoinStyle)
 
void SetFont (PdfFont *pFont)
 
void SetTextRenderingMode (EPdfTextRenderingMode mode)
 
EPdfTextRenderingMode GetTextRenderingMode (void) const
 
PdfFontGetFont () const
 
void SetClipRect (double dX, double dY, double dWidth, double dHeight)
 
void SetClipRect (const PdfRect &rRect)
 
void SetMiterLimit (double value)
 
void DrawLine (double dStartX, double dStartY, double dEndX, double dEndY)
 
void Rectangle (double dX, double dY, double dWidth, double dHeight, double dRoundX=0.0, double dRoundY=0.0)
 
void Rectangle (const PdfRect &rRect, double dRoundX=0.0, double dRoundY=0.0)
 
void Ellipse (double dX, double dY, double dWidth, double dHeight)
 
void Circle (double dX, double dY, double dRadius)
 
void DrawText (double dX, double dY, const PdfString &sText)
 
void DrawText (double dX, double dY, const PdfString &sText, long lLen)
 
void DrawMultiLineText (double dX, double dY, double dWidth, double dHeight, const PdfString &rsText, EPdfAlignment eAlignment=ePdfAlignment_Left, EPdfVerticalAlignment eVertical=ePdfVerticalAlignment_Top, bool bClip=true, bool bSkipSpaces=true)
 
void DrawMultiLineText (const PdfRect &rRect, const PdfString &rsText, EPdfAlignment eAlignment=ePdfAlignment_Left, EPdfVerticalAlignment eVertical=ePdfVerticalAlignment_Top, bool bClip=true, bool bSkipSpaces=true)
 
std::vector< PdfStringGetMultiLineTextAsLines (double dWidth, const PdfString &rsText, bool bSkipSpaces=true)
 
void DrawTextAligned (double dX, double dY, double dWidth, const PdfString &rsText, EPdfAlignment eAlignment)
 
void BeginText (double dX, double dY)
 
void AddText (const PdfString &sText)
 
void AddText (const PdfString &sText, pdf_long lStringLen)
 
void MoveTextPos (double dX, double dY)
 
void EndText ()
 
void DrawGlyph (PdfMemDocument *pDocument, double dX, double dY, const char *pszGlyphname)
 
void DrawImage (double dX, double dY, PdfImage *pObject, double dScaleX=1.0, double dScaleY=1.0)
 
void DrawXObject (double dX, double dY, PdfXObject *pObject, double dScaleX=1.0, double dScaleY=1.0)
 
void ClosePath ()
 
void LineTo (double dX, double dY)
 
void MoveTo (double dX, double dY)
 
void CubicBezierTo (double dX1, double dY1, double dX2, double dY2, double dX3, double dY3)
 
void HorizontalLineTo (double dX)
 
void VerticalLineTo (double dY)
 
void SmoothCurveTo (double dX2, double dY2, double dX3, double dY3)
 
void QuadCurveTo (double dX1, double dY1, double dX3, double dY3)
 
void SmoothQuadCurveTo (double dX3, double dY3)
 
void ArcTo (double dX, double dY, double dRadiusX, double dRadiusY, double dRotation, bool bLarge, bool bSweep)
 
void Close ()
 
void Stroke ()
 
void Fill (bool useEvenOddRule=false)
 
void FillAndStroke (bool useEvenOddRule=false)
 
void Clip (bool useEvenOddRule=false)
 
void EndPath (void)
 
void Save ()
 
void Restore ()
 
void SetTransformationMatrix (double a, double b, double c, double d, double e, double f)
 
void SetExtGState (PdfExtGState *inGState)
 
void SetRenderingIntent (char *intent)
 
void SetTabWidth (unsigned short nTabWidth)
 
unsigned short GetTabWidth () const
 
void SetPrecision (unsigned short inPrec)
 
unsigned short GetPrecision () const
 
std::ostringstream & GetCurrentPath (void)
 
void SetDependICCProfileColor (const PdfColor &rColor, const std::string &pCSTag)
 

Protected Member Functions

void ConvertRectToBezier (double dX, double dY, double dWidth, double dHeight, double pdPointX[], double pdPointY[])
 
virtual void AddToPageResources (const PdfName &rIdentifier, const PdfReference &rRef, const PdfName &rName)
 
void SetCurrentStrokingColor ()
 
PdfString ExpandTabs (const PdfString &rsString, pdf_long lLen) const
 

Protected Attributes

PdfStreamm_pCanvas
 
PdfCanvasm_pPage
 
PdfFontm_pFont
 
unsigned short m_nTabWidth
 
PdfColor m_curColor
 
bool m_isTextOpen
 
std::ostringstream m_oss
 
std::ostringstream m_curPath
 
bool m_isCurColorICCDepend
 
std::string m_CSTag
 

Detailed Description

This class provides an easy to use painter object which allows you to draw on a PDF page object.

During all drawing operations, you are still able to access the stream of the object you are drawing on directly.

All functions that take coordinates expect these to be in PDF User Units. Keep in mind that PDF has its coordinate system origin at the bottom left corner.

Constructor & Destructor Documentation

◆ PdfPainter()

PoDoFo::PdfPainter::PdfPainter ( )

Create a new PdfPainter object.

Member Function Documentation

◆ AddText() [1/2]

void PoDoFo::PdfPainter::AddText ( const PdfString sText)

Draw a string on a page. You have to call BeginText before the first call of this function and EndText after the last call.

If you want more simpler text output and do not need the advanced text position features of MoveTextPos use DrawText which is easier.

Parameters
sTextthe text string which should be printed
See also
SetFont()
MoveTextPos()
EndText()

◆ AddText() [2/2]

void PoDoFo::PdfPainter::AddText ( const PdfString sText,
pdf_long  lStringLen 
)

Draw a string on a page. You have to call BeginText before the first call of this function and EndText after the last call.

If you want more simpler text output and do not need the advanced text position features of MoveTextPos use DrawText which is easier.

Parameters
sTextthe text string which should be printed
lStringLendraw only lLen characters of pszText
See also
SetFont()
MoveTextPos()
EndText()

◆ AddToPageResources()

void PoDoFo::PdfPainter::AddToPageResources ( const PdfName rIdentifier,
const PdfReference rRef,
const PdfName rName 
)
protectedvirtual

Register an object in the resource dictionary of this page so that it can be used for any following drawing operations.

Parameters
rIdentifieridentifier of this object, e.g. /Ft0
rRefreference to the object you want to register
rNameregister under this key in the resource dictionary

◆ ArcTo()

void PoDoFo::PdfPainter::ArcTo ( double  dX,
double  dY,
double  dRadiusX,
double  dRadiusY,
double  dRotation,
bool  bLarge,
bool  bSweep 
)

Append a Arc to the current path Matches the SVG 'A' operator.

Parameters
dXx coordinate of the start point
dYy coordinate of the start point
dRadiusXx coordinate of the end point, which is the new current point
dRadiusYy coordinate of the end point, which is the new current point
dRotationdegree of rotation in radians
bLargelarge or small portion of the arc
bSweepsweep?

◆ BeginText()

void PoDoFo::PdfPainter::BeginText ( double  dX,
double  dY 
)

Begin drawing multiple text strings on a page using a given font object. You have to call SetFont before calling this function.

If you want more simpler text output and do not need the advanced text position features of MoveTextPos use DrawText which is easier.

Parameters
dXthe x coordinate
dYthe y coordinate
See also
SetFont()
AddText()
MoveTextPos()
EndText()

◆ Circle()

void PoDoFo::PdfPainter::Circle ( double  dX,
double  dY,
double  dRadius 
)

Add a circle into the current path

Parameters
dXx center coordinate of the circle
dYy coordinate of the circle
dRadiusradius of the circle

◆ Clip()

void PoDoFo::PdfPainter::Clip ( bool  useEvenOddRule = false)

Clip the current path. Matches the PDF 'W' operator. This function is useful to construct an own path for drawing or clipping.

Parameters
useEvenOddRuleselect even-odd rule instead of nonzero winding number rule

◆ Close()

void PoDoFo::PdfPainter::Close ( )

Close the current path. Matches the PDF 'h' operator.

◆ ClosePath()

void PoDoFo::PdfPainter::ClosePath ( )

Closes the current path by drawing a line from the current point to the starting point of the path. Matches the PDF 'h' operator. This function is useful to construct an own path for drawing or clipping.

◆ ConvertRectToBezier()

void PoDoFo::PdfPainter::ConvertRectToBezier ( double  dX,
double  dY,
double  dWidth,
double  dHeight,
double  pdPointX[],
double  pdPointY[] 
)
protected

Coverts a rectangle to an array of points which can be used to draw an ellipse using 4 bezier curves.

The arrays plPointX and plPointY need space for at least 12 longs to be stored.

Parameters
dXx position of the bounding rectangle
dYy position of the bounding rectangle
dWidthwidth of the bounding rectangle
dHeightheight of the bounding rectangle
pdPointXpointer to an array were the x coordinates of the resulting points will be stored
pdPointYpointer to an array were the y coordinates of the resulting points will be stored

◆ CubicBezierTo()

void PoDoFo::PdfPainter::CubicBezierTo ( double  dX1,
double  dY1,
double  dX2,
double  dY2,
double  dX3,
double  dY3 
)

Append a cubic bezier curve to the current path Matches the PDF 'c' operator.

Parameters
dX1x coordinate of the first control point
dY1y coordinate of the first control point
dX2x coordinate of the second control point
dY2y coordinate of the second control point
dX3x coordinate of the end point, which is the new current point
dY3y coordinate of the end point, which is the new current point

◆ DrawGlyph()

void PoDoFo::PdfPainter::DrawGlyph ( PdfMemDocument pDocument,
double  dX,
double  dY,
const char *  pszGlyphname 
)

Draw a single glyph on a page using a given font object.

Parameters
pDocumentpointer to the document, needed to generate a copy of the current font
dXthe x coordinate
dYthe y coordinate
pszGlyphnamethe name of the glyph which should be printed
See also
SetFont()

◆ DrawImage()

void PoDoFo::PdfPainter::DrawImage ( double  dX,
double  dY,
PdfImage pObject,
double  dScaleX = 1.0,
double  dScaleY = 1.0 
)

Draw an image on the current page.

Parameters
dXthe x coordinate (bottom left position of the image)
dYthe y coordinate (bottom position of the image)
pObjectan PdfXObject
dScaleXoption scaling factor in x direction
dScaleYoption scaling factor in y direction

◆ DrawLine()

void PoDoFo::PdfPainter::DrawLine ( double  dStartX,
double  dStartY,
double  dEndX,
double  dEndY 
)

Draw a line with the current color and line settings.

Parameters
dStartXx coordinate of the starting point
dStartYy coordinate of the starting point
dEndXx coordinate of the ending point
dEndYy coordinate of the ending point

◆ DrawMultiLineText() [1/2]

void PoDoFo::PdfPainter::DrawMultiLineText ( const PdfRect rRect,
const PdfString rsText,
EPdfAlignment  eAlignment = ePdfAlignment_Left,
EPdfVerticalAlignment  eVertical = ePdfVerticalAlignment_Top,
bool  bClip = true,
bool  bSkipSpaces = true 
)
inline

Draw multiline text into a rectangle doing automatic wordwrapping. The current font is used and SetFont has to be called at least once before using this function

Parameters
rRectbounding rectangle of the text
rsTextthe text which should be drawn
eAlignmentalignment of the individual text lines in the given bounding box
eVerticalvertical alignment of the text in the given bounding box
bClipset the clipping rectangle to the given rRect, otherwise no clipping is performed
bSkipSpaceswhether the trailing whitespaces should be skipped, so that next line doesn't start with whitespace

◆ DrawMultiLineText() [2/2]

void PoDoFo::PdfPainter::DrawMultiLineText ( double  dX,
double  dY,
double  dWidth,
double  dHeight,
const PdfString rsText,
EPdfAlignment  eAlignment = ePdfAlignment_Left,
EPdfVerticalAlignment  eVertical = ePdfVerticalAlignment_Top,
bool  bClip = true,
bool  bSkipSpaces = true 
)

Draw multiline text into a rectangle doing automatic wordwrapping. The current font is used and SetFont has to be called at least once before using this function

Parameters
dXthe x coordinate of the text area (left)
dYthe y coordinate of the text area (bottom)
dWidthwidth of the text area
dHeightheight of the text area
rsTextthe text which should be drawn
eAlignmentalignment of the individual text lines in the given bounding box
eVerticalvertical alignment of the text in the given bounding box
bClipset the clipping rectangle to the given rRect, otherwise no clipping is performed
bSkipSpaceswhether the trailing whitespaces should be skipped, so that next line doesn't start with whitespace

◆ DrawText() [1/2]

void PoDoFo::PdfPainter::DrawText ( double  dX,
double  dY,
const PdfString sText 
)

Draw a single-line text string on a page using a given font object. You have to call SetFont before calling this function.

Parameters
dXthe x coordinate
dYthe y coordinate
sTextthe text string which should be printed
See also
SetFont()

◆ DrawText() [2/2]

void PoDoFo::PdfPainter::DrawText ( double  dX,
double  dY,
const PdfString sText,
long  lLen 
)

Draw a single-line text string on a page using a given font object. You have to call SetFont before calling this function.

Parameters
dXthe x coordinate
dYthe y coordinate
sTextthe text string which should be printed (is not allowed to be NULL!)
lLendraw only lLen characters of pszText
See also
SetFont()

◆ DrawTextAligned()

void PoDoFo::PdfPainter::DrawTextAligned ( double  dX,
double  dY,
double  dWidth,
const PdfString rsText,
EPdfAlignment  eAlignment 
)

Draw a single line of text horizontally aligned.

Parameters
dXthe x coordinate of the text line
dYthe y coordinate of the text line
dWidththe width of the text line
rsTextthe text to draw
eAlignmentalignment of the text line

◆ DrawXObject()

void PoDoFo::PdfPainter::DrawXObject ( double  dX,
double  dY,
PdfXObject pObject,
double  dScaleX = 1.0,
double  dScaleY = 1.0 
)

Draw an XObject on the current page. For PdfImage use DrawImage.

Parameters
dXthe x coordinate (bottom left position of the XObject)
dYthe y coordinate (bottom position of the XObject)
pObjectan PdfXObject
dScaleXoption scaling factor in x direction
dScaleYoption scaling factor in y direction
See also
DrawImage

◆ Ellipse()

void PoDoFo::PdfPainter::Ellipse ( double  dX,
double  dY,
double  dWidth,
double  dHeight 
)

Add an ellipse into the current path

Parameters
dXx coordinate of the ellipse (left coordinate)
dYy coordinate of the ellipse (top coordinate)
dWidthwidth of the ellipse
dHeightabsolute height of the ellipse

◆ EndPath()

void PoDoFo::PdfPainter::EndPath ( void  )

End current pathm without filling or stroking it. Matches the PDF 'n' operator.

◆ EndText()

void PoDoFo::PdfPainter::EndText ( )

End drawing multiple text strings on a page

If you want more simpler text output and do not need the advanced text position features of MoveTextPos use DrawText which is easier.

See also
BeginText()
AddText()
MoveTextPos()

◆ ExpandTabs()

PdfString PoDoFo::PdfPainter::ExpandTabs ( const PdfString rsString,
pdf_long  lLen 
) const
protected

Expand all tab characters in a string using spaces.

Parameters
rsStringexpand all tabs in this string using spaces
lLenuse only lLen characters of rsString
Returns
an expanded copy of the passed string
See also
SetTabWidth

◆ Fill()

void PoDoFo::PdfPainter::Fill ( bool  useEvenOddRule = false)

Fill the current path. Matches the PDF 'f' operator. This function is useful to construct an own path for drawing or clipping.

Parameters
useEvenOddRuleselect even-odd rule instead of nonzero winding number rule

◆ FillAndStroke()

void PoDoFo::PdfPainter::FillAndStroke ( bool  useEvenOddRule = false)

Fill then stroke the current path. Matches the PDF 'B' operator.

Parameters
useEvenOddRuleselect even-odd rule instead of nonzero winding number rule

◆ FinishPage()

void PoDoFo::PdfPainter::FinishPage ( )

Finish drawing onto a page.

This has to be called whenever a page has been drawn complete.

◆ GetCanvas()

PdfStream * PoDoFo::PdfPainter::GetCanvas ( ) const
inline

Return the current page canvas stream that is set on the painter.

Returns
the current page canvas stream of the painter or NULL if none is set

◆ GetCurrentPath()

std::ostringstream & PoDoFo::PdfPainter::GetCurrentPath ( void  )
inline

Get current path string stream. Stroke/Fill commands clear current path.

Returns
std::ostringstream representing current path

◆ GetFont()

PdfFont * PoDoFo::PdfPainter::GetFont ( ) const
inline

Get the current font:

Returns
a font object or NULL if no font was set.

◆ GetMultiLineTextAsLines()

std::vector< PdfString > PoDoFo::PdfPainter::GetMultiLineTextAsLines ( double  dWidth,
const PdfString rsText,
bool  bSkipSpaces = true 
)

Gets the text divided into individual lines, using the current font and clipping rectangle.

Parameters
dWidthwidth of the text area
rsTextthe text which should be drawn
bSkipSpaceswhether the trailing whitespaces should be skipped, so that next line doesn't start with whitespace

◆ GetPage()

PdfCanvas * PoDoFo::PdfPainter::GetPage ( ) const
inline

Return the current page that is that on the painter.

Returns
the current page of the painter or NULL if none is set

◆ GetPrecision()

unsigned short PoDoFo::PdfPainter::GetPrecision ( ) const
inline

Get the currently set floating point precision

Returns
how many decimal places will be written out for any floating point value

◆ GetTabWidth()

unsigned short PoDoFo::PdfPainter::GetTabWidth ( ) const
inline

Get the currently set tab width

Returns
by how many spaces a tabulator will be replaced
See also
DrawText
TabWidth

◆ GetTextRenderingMode()

EPdfTextRenderingMode PoDoFo::PdfPainter::GetTextRenderingMode ( void  ) const
inline

Gets current text rendering mode. Default mode is ePdfTextRenderingMode_Fill.

◆ HorizontalLineTo()

void PoDoFo::PdfPainter::HorizontalLineTo ( double  dX)

Append a horizontal line to the current path Matches the SVG 'H' operator

Parameters
dXx coordinate to draw the line to

◆ LineTo()

void PoDoFo::PdfPainter::LineTo ( double  dX,
double  dY 
)

Append a line segment to the current path. Matches the PDF 'l' operator. This function is useful to construct an own path for drawing or clipping.

Parameters
dXx position
dYy position

◆ MoveTextPos()

void PoDoFo::PdfPainter::MoveTextPos ( double  dX,
double  dY 
)

Move position for text drawing on a page. You have to call BeginText before calling this function

If you want more simpler text output and do not need the advanced text position features of MoveTextPos use DrawText which is easier.

Parameters
dXthe x offset relative to pos of BeginText or last MoveTextPos
dYthe y offset relative to pos of BeginText or last MoveTextPos
See also
BeginText()
AddText()
EndText()

◆ MoveTo()

void PoDoFo::PdfPainter::MoveTo ( double  dX,
double  dY 
)

Begin a new path. Matches the PDF 'm' operator. This function is useful to construct an own path for drawing or clipping.

Parameters
dXx position
dYy position

◆ QuadCurveTo()

void PoDoFo::PdfPainter::QuadCurveTo ( double  dX1,
double  dY1,
double  dX3,
double  dY3 
)

Append a quadratic bezier curve to the current path Matches the SVG 'Q' operator.

Parameters
dX1x coordinate of the first control point
dY1y coordinate of the first control point
dX3x coordinate of the end point, which is the new current point
dY3y coordinate of the end point, which is the new current point

◆ Rectangle() [1/2]

void PoDoFo::PdfPainter::Rectangle ( const PdfRect rRect,
double  dRoundX = 0.0,
double  dRoundY = 0.0 
)
inline

Add a rectangle into the current path

Parameters
rRectthe rectangle area
dRoundXrounding factor, x direction
dRoundYrounding factor, y direction
See also
DrawRect

◆ Rectangle() [2/2]

void PoDoFo::PdfPainter::Rectangle ( double  dX,
double  dY,
double  dWidth,
double  dHeight,
double  dRoundX = 0.0,
double  dRoundY = 0.0 
)

Add a rectangle into the current path

Parameters
dXx coordinate of the rectangle (left coordinate)
dYy coordinate of the rectangle (bottom coordinate)
dWidthwidth of the rectangle
dHeightabsolute height of the rectangle
dRoundXrounding factor, x direction
dRoundYrounding factor, y direction

◆ Restore()

void PoDoFo::PdfPainter::Restore ( )

Restore the current graphics settings from the graphics stack. Operator 'Q' in PDF. This call has to be balanced with a corresponding call to Save()!

See also
Save

◆ Save()

void PoDoFo::PdfPainter::Save ( )

Save the current graphics settings onto the graphics stack. Operator 'q' in PDF. This call has to be balanced with a corresponding call to Restore()!

See also
Restore

◆ SetClipRect() [1/2]

void PoDoFo::PdfPainter::SetClipRect ( const PdfRect rRect)
inline

Set a clipping rectangle

Parameters
rRectrectangle

◆ SetClipRect() [2/2]

void PoDoFo::PdfPainter::SetClipRect ( double  dX,
double  dY,
double  dWidth,
double  dHeight 
)

Set a clipping rectangle

Parameters
dXx coordinate of the rectangle (left coordinate)
dYy coordinate of the rectangle (bottom coordinate)
dWidthwidth of the rectangle
dHeightabsolute height of the rectangle

◆ SetColor() [1/2]

void PoDoFo::PdfPainter::SetColor ( const PdfColor rColor)

Set the color for all following non-stroking operations.

Parameters
rColora PdfColor object

◆ SetColor() [2/2]

void PoDoFo::PdfPainter::SetColor ( double  r,
double  g,
double  b 
)

Set the color for all following non-stroking operations in rgb colorspace. This operation used the 'rg' PDF operator.

This color is also used when drawing text.

Parameters
rred value in the range 0.0 - 1.0
ggreen value in the range 0.0 - 1.0
bblue value in the range 0.0 - 1.0

◆ SetColorCMYK()

void PoDoFo::PdfPainter::SetColorCMYK ( double  c,
double  m,
double  y,
double  k 
)

Set the color for all following non-stroking operations in cmyk colorspace. This operation used the 'k' PDF operator.

Parameters
ccyan value in the range 0.0 - 1.0
mmagenta value in the range 0.0 - 1.0
yyellow value in the range 0.0 - 1.0
kblack value in the range 0.0 - 1.0

◆ SetCurrentStrokingColor()

void PoDoFo::PdfPainter::SetCurrentStrokingColor ( )
protected

Sets the color that was last set by the user as the current stroking color. You should always enclose this function by Save() and Restore()

See also
Save()
Restore()

◆ SetDependICCProfileColor()

void PoDoFo::PdfPainter::SetDependICCProfileColor ( const PdfColor rColor,
const std::string &  pCSTag 
)

Set rgb color that depend on color space setting, "cs" tag.

Parameters
rColora PdfColor object
pCSTaga CS tag used in PdfPage::SetICCProfile
See also
PdfPage::SetICCProfile()

◆ SetExtGState()

void PoDoFo::PdfPainter::SetExtGState ( PdfExtGState inGState)

Sets a specific PdfExtGState as being active

Parameters
inGStatethe specific ExtGState to set

◆ SetFont()

void PoDoFo::PdfPainter::SetFont ( PdfFont pFont)

Set the font for all text drawing operations

Parameters
pFonta handle to a valid PdfFont object
See also
DrawText

◆ SetGray()

void PoDoFo::PdfPainter::SetGray ( double  g)

Set the color for all following non-stroking operations in grayscale colorspace. This operation used the 'g' PDF operator.

Parameters
ggray scale value in the range 0.0 - 1.0

◆ SetLineCapStyle()

void PoDoFo::PdfPainter::SetLineCapStyle ( EPdfLineCapStyle  eCapStyle)

Set the line cap style for all stroking operations.

Parameters
eCapStylethe cap style.

Possible values: ePdfLineCapStyle_Butt, ePdfLineCapStyle_Round, ePdfLineCapStyle_Square

◆ SetLineJoinStyle()

void PoDoFo::PdfPainter::SetLineJoinStyle ( EPdfLineJoinStyle  eJoinStyle)

Set the line join style for all stroking operations.

Parameters
eJoinStylethe join style.

Possible values: ePdfLineJoinStyle_Miter ePdfLineJoinStyle_Round ePdfLineJoinStyle_Bevel

◆ SetMiterLimit()

void PoDoFo::PdfPainter::SetMiterLimit ( double  value)

Set miter limit.

◆ SetPage()

void PoDoFo::PdfPainter::SetPage ( PdfCanvas pPage)

Set the page on which the painter should draw. The painter will draw of course on the pages contents object.

Calls FinishPage() on the last page if it was not yet called.

Parameters
pPagea PdfCanvas object (most likely a PdfPage or PdfXObject).
See also
PdfPage
PdfXObject
FinishPage()
GetPage()

◆ SetPrecision()

void PoDoFo::PdfPainter::SetPrecision ( unsigned short  inPrec)
inline

Set the floating point precision.

Parameters
inPrecwrite this many decimal places

◆ SetRenderingIntent()

void PoDoFo::PdfPainter::SetRenderingIntent ( char *  intent)

Sets a specific rendering intent

Parameters
intentthe specific intent to set

◆ SetShadingPattern()

void PoDoFo::PdfPainter::SetShadingPattern ( const PdfShadingPattern rPattern)

Set the shading pattern for all following non-stroking operations. This operation uses the 'scn' PDF operator.

Parameters
rPatterna shading pattern

◆ SetStrokeStyle()

void PoDoFo::PdfPainter::SetStrokeStyle ( EPdfStrokeStyle  eStyle,
const char *  pszCustom = NULL,
bool  inverted = false,
double  scale = 1.0,
bool  subtractJoinCap = false 
)

Set the stoke style for all stroking operations.

Parameters
eStylestyle of the stroking operations
pszCustoma custom stroking style which is used when eStyle == ePdfStrokeStyle_Custom.
invertedinverted dash style (gaps for drawn spaces), it is ignored for None, Solid and Custom styles
scalescale factor of the stroke style it is ignored for None, Solid and Custom styles
subtractJoinCapif true, subtracts scaled width on filled parts, thus the line capability still draws into the cell; is used only if scale is not 1.0

Possible values: ePdfStrokeStyle_None ePdfStrokeStyle_Solid ePdfStrokeStyle_Dash ePdfStrokeStyle_Dot ePdfStrokeStyle_DashDot ePdfStrokeStyle_DashDotDot ePdfStrokeStyle_Custom

◆ SetStrokeWidth()

void PoDoFo::PdfPainter::SetStrokeWidth ( double  dWidth)

Set the line width for all stroking operations.

Parameters
dWidthin PDF User Units.

◆ SetStrokingColor() [1/2]

void PoDoFo::PdfPainter::SetStrokingColor ( const PdfColor rColor)

Set the color for all following stroking operations.

Parameters
rColora PdfColor object

◆ SetStrokingColor() [2/2]

void PoDoFo::PdfPainter::SetStrokingColor ( double  r,
double  g,
double  b 
)

Set the color for all following stroking operations in rgb colorspace. This operation used the 'RG' PDF operator.

Parameters
rred value in the range 0.0 - 1.0
ggreen value in the range 0.0 - 1.0
bblue value in the range 0.0 - 1.0

◆ SetStrokingColorCMYK()

void PoDoFo::PdfPainter::SetStrokingColorCMYK ( double  c,
double  m,
double  y,
double  k 
)

Set the color for all following stroking operations in cmyk colorspace. This operation used the 'K' PDF operator.

Parameters
ccyan value in the range 0.0 - 1.0
mmagenta value in the range 0.0 - 1.0
yyellow value in the range 0.0 - 1.0
kblack value in the range 0.0 - 1.0

◆ SetStrokingGray()

void PoDoFo::PdfPainter::SetStrokingGray ( double  g)

Set the color for all following stroking operations in grayscale colorspace. This operation used the 'G' PDF operator.

Parameters
ggray scale value in the range 0.0 - 1.0

◆ SetStrokingShadingPattern()

void PoDoFo::PdfPainter::SetStrokingShadingPattern ( const PdfShadingPattern rPattern)

Set the shading pattern for all following stroking operations. This operation uses the 'SCN' PDF operator.

Parameters
rPatterna shading pattern

◆ SetStrokingTilingPattern() [1/2]

void PoDoFo::PdfPainter::SetStrokingTilingPattern ( const PdfTilingPattern rPattern)

Set the tiling pattern for all following stroking operations. This operation uses the 'SCN' PDF operator.

Parameters
rPatterna tiling pattern

◆ SetStrokingTilingPattern() [2/2]

void PoDoFo::PdfPainter::SetStrokingTilingPattern ( const std::string &  rPatternName)

Set the tiling pattern for all following stroking operations by pattern name, Use when it's already in resources. This operation uses the 'SCN' PDF operator.

Parameters
rPatternNamea tiling pattern name

◆ SetTabWidth()

void PoDoFo::PdfPainter::SetTabWidth ( unsigned short  nTabWidth)
inline

Set the tab width for the DrawText operation. Every tab '\t' is replaced with nTabWidth spaces before drawing text. Default is a value of 4

Parameters
nTabWidthreplace every tabulator by this much spaces
See also
DrawText
TabWidth

◆ SetTextRenderingMode()

void PoDoFo::PdfPainter::SetTextRenderingMode ( EPdfTextRenderingMode  mode)

Set the text rendering mode

Parameters
modeWhat text rendering mode to use.

Possible values: ePdfTextRenderingMode_Fill (default mode) ePdfTextRenderingMode_Stroke ePdfTextRenderingMode_FillAndStroke ePdfTextRenderingMode_Invisible ePdfTextRenderingMode_FillToClipPath ePdfTextRenderingMode_StrokeToClipPath ePdfTextRenderingMode_FillAndStrokeToClipPath ePdfTextRenderingMode_ToClipPath

◆ SetTilingPattern() [1/2]

void PoDoFo::PdfPainter::SetTilingPattern ( const PdfTilingPattern rPattern)

Set the tiling pattern for all following non-stroking operations. This operation uses the 'scn' PDF operator.

Parameters
rPatterna tiling pattern

◆ SetTilingPattern() [2/2]

void PoDoFo::PdfPainter::SetTilingPattern ( const std::string &  rPatternName)

Set the tiling pattern for all following non-stroking operations by pattern name. Use when it's already in resources. This operation uses the 'scn' PDF operator.

Parameters
rPatterna tiling pattern

◆ SetTransformationMatrix()

void PoDoFo::PdfPainter::SetTransformationMatrix ( double  a,
double  b,
double  c,
double  d,
double  e,
double  f 
)

Set the transformation matrix for the current coordinate system See the operator 'cm' in PDF.

The six parameters are a standard 3x3 transformation matrix where the 3 left parameters are 0 0 1.

Parameters
ascale in x direction
brotation
crotation
dscale in y direction
etranslate in x direction
ftranslate in y direction
See also
Save()
Restore()

◆ SmoothCurveTo()

void PoDoFo::PdfPainter::SmoothCurveTo ( double  dX2,
double  dY2,
double  dX3,
double  dY3 
)

Append a smooth bezier curve to the current path Matches the SVG 'S' operator.

Parameters
dX2x coordinate of the second control point
dY2y coordinate of the second control point
dX3x coordinate of the end point, which is the new current point
dY3y coordinate of the end point, which is the new current point

◆ SmoothQuadCurveTo()

void PoDoFo::PdfPainter::SmoothQuadCurveTo ( double  dX3,
double  dY3 
)

Append a smooth quadratic bezier curve to the current path Matches the SVG 'T' operator.

Parameters
dX3x coordinate of the end point, which is the new current point
dY3y coordinate of the end point, which is the new current point

◆ Stroke()

void PoDoFo::PdfPainter::Stroke ( )

Stroke the current path. Matches the PDF 'S' operator. This function is useful to construct an own path for drawing or clipping.

◆ VerticalLineTo()

void PoDoFo::PdfPainter::VerticalLineTo ( double  dY)

Append a vertical line to the current path Matches the SVG 'V' operator

Parameters
dYy coordinate to draw the line to

Member Data Documentation

◆ m_CSTag

std::string PoDoFo::PdfPainter::m_CSTag
protected

ColorSpace tag

◆ m_curColor

PdfColor PoDoFo::PdfPainter::m_curColor
protected

Save the current color for non stroking colors

◆ m_curPath

std::ostringstream PoDoFo::PdfPainter::m_curPath
protected

current path

◆ m_isCurColorICCDepend

bool PoDoFo::PdfPainter::m_isCurColorICCDepend
protected

True if should use color with ICC Profile

◆ m_isTextOpen

bool PoDoFo::PdfPainter::m_isTextOpen
protected

Is between BT and ET

◆ m_nTabWidth

unsigned short PoDoFo::PdfPainter::m_nTabWidth
protected

Every tab '\t' is replaced with m_nTabWidth spaces before drawing text. Default is a value of 4

◆ m_oss

std::ostringstream PoDoFo::PdfPainter::m_oss
protected

temporary stream buffer

◆ m_pCanvas

PdfStream* PoDoFo::PdfPainter::m_pCanvas
protected

All drawing operations work on this stream. This object may not be NULL. If it is NULL any function accessing it should return ERROR_PDF_INVALID_HANDLE

◆ m_pFont

PdfFont* PoDoFo::PdfPainter::m_pFont
protected

Font for all drawing operations

◆ m_pPage

PdfCanvas* PoDoFo::PdfPainter::m_pPage
protected

The page object is needed so that fonts etc. can be added to the page resource dictionary as appropriate.