|
pdfmm 0.9.20
|
#include <PdfPainter.h>
Public Member Functions | |
| PdfPainter (PdfPainterFlags flags=PdfPainterFlags::None) | |
| void | SetCanvas (PdfCanvas *page) |
| void | FinishDrawing () |
| void | SetStrokingShadingPattern (const PdfShadingPattern &pattern) |
| void | SetShadingPattern (const PdfShadingPattern &pattern) |
| void | SetStrokingTilingPattern (const PdfTilingPattern &pattern) |
| void | SetStrokingTilingPattern (const std::string_view &patternName) |
| void | SetTilingPattern (const PdfTilingPattern &pattern) |
| void | SetTilingPattern (const std::string_view &patternName) |
| void | SetStrokingColor (const PdfColor &color) |
| void | SetColor (const PdfColor &color) |
| void | SetStrokeWidth (double width) |
| void | SetStrokeStyle (PdfStrokeStyle strokeStyle, const std::string_view &custom={ }, bool inverted=false, double scale=1.0, bool subtractJoinCap=false) |
| void | SetLineCapStyle (PdfLineCapStyle capStyle) |
| void | SetLineJoinStyle (PdfLineJoinStyle joinStyle) |
| void | SetFont (PdfFont *font) |
| void | SetTextRenderingMode (PdfTextRenderingMode mode) |
| void | SetClipRect (double x, double y, double width, double height) |
| void | SetClipRect (const PdfRect &rect) |
| void | SetMiterLimit (double value) |
| void | DrawLine (double startX, double startY, double endX, double endY) |
| void | Rectangle (double x, double y, double width, double height, double roundX=0.0, double roundY=0.0) |
| void | Rectangle (const PdfRect &rect, double roundX=0.0, double roundY=0.0) |
| void | Ellipse (double x, double y, double width, double height) |
| void | Circle (double x, double y, double radius) |
| void | DrawText (double x, double y, const std::string_view &str) |
| void | DrawMultiLineText (double x, double y, double width, double height, const std::string_view &str, PdfHorizontalAlignment hAlignment=PdfHorizontalAlignment::Left, PdfVerticalAlignment vAlignment=PdfVerticalAlignment::Top, bool clip=true, bool skipSpaces=true) |
| void | DrawMultiLineText (const PdfRect &rect, const std::string_view &str, PdfHorizontalAlignment hAlignment=PdfHorizontalAlignment::Left, PdfVerticalAlignment vAlignment=PdfVerticalAlignment::Top, bool clip=true, bool skipSpaces=true) |
| void | DrawTextAligned (double x, double y, double width, const std::string_view &str, PdfHorizontalAlignment hAlignment) |
| void | BeginText (double x, double y) |
| void | AddText (const std::string_view &str) |
| void | MoveTextPos (double x, double y) |
| void | EndText () |
| void | DrawImage (double x, double y, const PdfImage &obj, double scaleX=1.0, double scaleY=1.0) |
| void | DrawXObject (double x, double y, const PdfXObject &obj, double scaleX=1.0, double scaleY=1.0) |
| void | ClosePath () |
| void | LineTo (double x, double y) |
| void | MoveTo (double x, double y) |
| void | CubicBezierTo (double x1, double y1, double x2, double y2, double x3, double y3) |
| void | HorizontalLineTo (double x) |
| void | VerticalLineTo (double y) |
| void | SmoothCurveTo (double x2, double y2, double x3, double y3) |
| void | QuadCurveTo (double x1, double y1, double x3, double y3) |
| void | SmoothQuadCurveTo (double x3, double y3) |
| void | ArcTo (double x, double y, double radiusX, double radiusY, double rotation, bool large, bool sweep) |
| void | Close () |
| void | Stroke () |
| void | Fill (bool useEvenOddRule=false) |
| void | FillAndStroke (bool useEvenOddRule=false) |
| void | Clip (bool useEvenOddRule=false) |
| void | EndPath () |
| void | Save () |
| void | Restore () |
| void | SetTransformationMatrix (double a, double b, double c, double d, double e, double f) |
| void | SetExtGState (const PdfExtGState &inGState) |
| void | SetRenderingIntent (const std::string_view &intent) |
| void | SetPrecision (unsigned short precision) |
| unsigned short | GetPrecision () const |
| void | SetDependICCProfileColor (const PdfColor &color, const std::string_view &csTag) |
| PdfTextRenderingMode | GetTextRenderingMode () const |
| PdfFont * | GetFont () const |
| void | SetTabWidth (unsigned short tabWidth) |
| unsigned short | GetTabWidth () const |
| PdfCanvas * | GetCanvas () const |
| PdfStream * | GetStream () const |
| std::ostringstream & | GetCurrentPath () |
| std::ostringstream & | GetStream () |
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.
| PdfPainter::PdfPainter | ( | PdfPainterFlags | flags = PdfPainterFlags::None | ) |
Create a new PdfPainter object.
| saveRestore | do save/restore state before appending |
| void PdfPainter::AddText | ( | const std::string_view & | str | ) |
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.
| sText | the text string which should be printed |
| void PdfPainter::ArcTo | ( | double | x, |
| double | y, | ||
| double | radiusX, | ||
| double | radiusY, | ||
| double | rotation, | ||
| bool | large, | ||
| bool | sweep | ||
| ) |
Append a Arc to the current path Matches the SVG 'A' operator.
| x | x coordinate of the start point |
| y | y coordinate of the start point |
| dRadiusX | x coordinate of the end point, which is the new current point |
| dRadiusY | y coordinate of the end point, which is the new current point |
| dRotation | degree of rotation in radians |
| bLarge | large or small portion of the arc |
| bSweep | sweep? |
| void PdfPainter::BeginText | ( | double | x, |
| double | y | ||
| ) |
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.
| x | the x coordinate |
| y | the y coordinate |
| void PdfPainter::Circle | ( | double | x, |
| double | y, | ||
| double | radius | ||
| ) |
Add a circle into the current path
| x | x center coordinate of the circle |
| y | y coordinate of the circle |
| dRadius | radius of the circle |
| void 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.
| useEvenOddRule | select even-odd rule instead of nonzero winding number rule |
| void PdfPainter::Close | ( | ) |
Close the current path. Matches the PDF 'h' operator.
| void 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.
| void PdfPainter::CubicBezierTo | ( | double | x1, |
| double | y1, | ||
| double | x2, | ||
| double | y2, | ||
| double | x3, | ||
| double | y3 | ||
| ) |
Append a cubic bezier curve to the current path Matches the PDF 'c' operator.
| x1 | x coordinate of the first control point |
| y1 | y coordinate of the first control point |
| x2 | x coordinate of the second control point |
| y2 | y coordinate of the second control point |
| x3 | x coordinate of the end point, which is the new current point |
| y3 | y coordinate of the end point, which is the new current point |
| void PdfPainter::DrawImage | ( | double | x, |
| double | y, | ||
| const PdfImage & | obj, | ||
| double | scaleX = 1.0, |
||
| double | scaleY = 1.0 |
||
| ) |
Draw an image on the current page.
| x | the x coordinate (bottom left position of the image) |
| y | the y coordinate (bottom position of the image) |
| obj | an PdfXObject |
| scaleX | option scaling factor in x direction |
| scaleY | option scaling factor in y direction |
| void PdfPainter::DrawLine | ( | double | startX, |
| double | startY, | ||
| double | endX, | ||
| double | endY | ||
| ) |
Draw a line with the current color and line settings.
| startX | x coordinate of the starting point |
| startY | y coordinate of the starting point |
| endX | x coordinate of the ending point |
| endY | y coordinate of the ending point |
| void mm::PdfPainter::DrawMultiLineText | ( | const PdfRect & | rect, |
| const std::string_view & | str, | ||
| PdfHorizontalAlignment | hAlignment = PdfHorizontalAlignment::Left, |
||
| PdfVerticalAlignment | vAlignment = PdfVerticalAlignment::Top, |
||
| bool | clip = true, |
||
| bool | skipSpaces = 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
| rect | bounding rectangle of the text |
| text | the text which should be drawn |
| eAlignment | alignment of the individual text lines in the given bounding box |
| eVertical | vertical alignment of the text in the given bounding box |
| bClip | set the clipping rectangle to the given rect, otherwise no clipping is performed |
| bSkipSpaces | whether the trailing whitespaces should be skipped, so that next line doesn't start with whitespace |
| void mm::PdfPainter::DrawMultiLineText | ( | double | x, |
| double | y, | ||
| double | width, | ||
| double | height, | ||
| const std::string_view & | str, | ||
| PdfHorizontalAlignment | hAlignment = PdfHorizontalAlignment::Left, |
||
| PdfVerticalAlignment | vAlignment = PdfVerticalAlignment::Top, |
||
| bool | clip = true, |
||
| bool | skipSpaces = 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
| x | the x coordinate of the text area (left) |
| y | the y coordinate of the text area (bottom) |
| width | width of the text area |
| height | height of the text area |
| text | the text which should be drawn |
| eAlignment | alignment of the individual text lines in the given bounding box |
| eVertical | vertical alignment of the text in the given bounding box |
| bClip | set the clipping rectangle to the given rect, otherwise no clipping is performed |
| bSkipSpaces | whether the trailing whitespaces should be skipped, so that next line doesn't start with whitespace |
| void PdfPainter::DrawText | ( | double | x, |
| double | y, | ||
| const std::string_view & | str | ||
| ) |
Draw a single-line text string on a page using a given font object. You have to call SetFont before calling this function.
| x | the x coordinate |
| y | the y coordinate |
| sText | the text string which should be printed |
| void PdfPainter::DrawTextAligned | ( | double | x, |
| double | y, | ||
| double | width, | ||
| const std::string_view & | str, | ||
| PdfHorizontalAlignment | hAlignment | ||
| ) |
Draw a single line of text horizontally aligned.
| x | the x coordinate of the text line |
| y | the y coordinate of the text line |
| width | the width of the text line |
| text | the text to draw |
| eAlignment | alignment of the text line |
| void PdfPainter::DrawXObject | ( | double | x, |
| double | y, | ||
| const PdfXObject & | obj, | ||
| double | scaleX = 1.0, |
||
| double | scaleY = 1.0 |
||
| ) |
Draw an XObject on the current page. For PdfImage use DrawImage.
| x | the x coordinate (bottom left position of the XObject) |
| y | the y coordinate (bottom position of the XObject) |
| obj | an PdfXObject |
| scaleX | option scaling factor in x direction |
| scaleY | option scaling factor in y direction |
| void PdfPainter::Ellipse | ( | double | x, |
| double | y, | ||
| double | width, | ||
| double | height | ||
| ) |
Add an ellipse into the current path
| x | x coordinate of the ellipse (left coordinate) |
| y | y coordinate of the ellipse (top coordinate) |
| width | width of the ellipse |
| height | absolute height of the ellipse |
| void PdfPainter::EndPath | ( | ) |
End current pathm without filling or stroking it. Matches the PDF 'n' operator.
| void 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.
| void 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.
| useEvenOddRule | select even-odd rule instead of nonzero winding number rule |
| void PdfPainter::FillAndStroke | ( | bool | useEvenOddRule = false | ) |
Fill then stroke the current path. Matches the PDF 'B' operator.
| useEvenOddRule | select even-odd rule instead of nonzero winding number rule |
| void PdfPainter::FinishDrawing | ( | ) |
Finish drawing onto a canvas.
This has to be called whenever a page has been drawn complete.
|
inline |
Return the current page that is that on the painter.
|
inline |
Get current path string stream. Stroke/Fill commands clear current path.
|
inline |
Get the current font:
| unsigned short PdfPainter::GetPrecision | ( | ) | const |
Get the currently set floating point precision
|
inline |
Get current temporary stream
|
inline |
Return the current canvas stream that is set on the painter.
|
inline |
Get the currently set tab width
|
inline |
Gets current text rendering mode. Default mode is PdfTextRenderingMode::Fill.
| void PdfPainter::HorizontalLineTo | ( | double | x | ) |
Append a horizontal line to the current path Matches the SVG 'H' operator
| x | x coordinate to draw the line to |
| void PdfPainter::LineTo | ( | double | x, |
| double | y | ||
| ) |
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.
| x | x position |
| y | y position |
| void PdfPainter::MoveTextPos | ( | double | x, |
| double | y | ||
| ) |
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.
| x | the x offset relative to pos of BeginText or last MoveTextPos |
| y | the y offset relative to pos of BeginText or last MoveTextPos |
| void PdfPainter::MoveTo | ( | double | x, |
| double | y | ||
| ) |
Begin a new path. Matches the PDF 'm' operator. This function is useful to construct an own path for drawing or clipping.
| x | x position |
| y | y position |
| void PdfPainter::QuadCurveTo | ( | double | x1, |
| double | y1, | ||
| double | x3, | ||
| double | y3 | ||
| ) |
Append a quadratic bezier curve to the current path Matches the SVG 'Q' operator.
| x1 | x coordinate of the first control point |
| y1 | y coordinate of the first control point |
| x3 | x coordinate of the end point, which is the new current point |
| y3 | y coordinate of the end point, which is the new current point |
| void PdfPainter::Rectangle | ( | const PdfRect & | rect, |
| double | roundX = 0.0, |
||
| double | roundY = 0.0 |
||
| ) |
Add a rectangle into the current path
| rect | the rectangle area |
| roundX | rounding factor, x direction |
| roundY | rounding factor, y direction |
| void PdfPainter::Rectangle | ( | double | x, |
| double | y, | ||
| double | width, | ||
| double | height, | ||
| double | roundX = 0.0, |
||
| double | roundY = 0.0 |
||
| ) |
Add a rectangle into the current path
| x | x coordinate of the rectangle (left coordinate) |
| y | y coordinate of the rectangle (bottom coordinate) |
| width | width of the rectangle |
| height | absolute height of the rectangle |
| roundX | rounding factor, x direction |
| roundY | rounding factor, y direction |
| void PdfPainter::Restore | ( | ) |
| void PdfPainter::Save | ( | ) |
| void PdfPainter::SetCanvas | ( | PdfCanvas * | page | ) |
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.
| page | a PdfCanvas object (most likely a PdfPage or PdfXObject). |
| void PdfPainter::SetClipRect | ( | const PdfRect & | rect | ) |
Set a clipping rectangle
| rect | rectangle |
| void PdfPainter::SetClipRect | ( | double | x, |
| double | y, | ||
| double | width, | ||
| double | height | ||
| ) |
Set a clipping rectangle
| x | x coordinate of the rectangle (left coordinate) |
| y | y coordinate of the rectangle (bottom coordinate) |
| width | width of the rectangle |
| height | absolute height of the rectangle |
| void PdfPainter::SetColor | ( | const PdfColor & | color | ) |
Set the color for all following non-stroking operations.
| color | a PdfColor object |
| void PdfPainter::SetDependICCProfileColor | ( | const PdfColor & | color, |
| const std::string_view & | csTag | ||
| ) |
Set rgb color that depend on color space setting, "cs" tag.
| color | a PdfColor object |
| csTag | a CS tag used in PdfPage::SetICCProfile |
| void PdfPainter::SetExtGState | ( | const PdfExtGState & | inGState | ) |
Sets a specific PdfExtGState as being active
| inGState | the specific ExtGState to set |
| void PdfPainter::SetFont | ( | PdfFont * | font | ) |
| void PdfPainter::SetLineCapStyle | ( | PdfLineCapStyle | capStyle | ) |
Set the line cap style for all stroking operations.
| eCapStyle | the cap style. |
Possible values: PdfLineCapStyle::Butt, PdfLineCapStyle::Round, PdfLineCapStyle::Square
| void PdfPainter::SetLineJoinStyle | ( | PdfLineJoinStyle | joinStyle | ) |
Set the line join style for all stroking operations.
| eJoinStyle | the join style. |
Possible values: PdfLineJoinStyle::Miter PdfLineJoinStyle::Round PdfLineJoinStyle::Bevel
| void PdfPainter::SetMiterLimit | ( | double | value | ) |
Set miter limit.
| void PdfPainter::SetPrecision | ( | unsigned short | precision | ) |
Set the floating point precision.
| precision | write this many decimal places |
| void PdfPainter::SetRenderingIntent | ( | const std::string_view & | intent | ) |
Sets a specific rendering intent
| intent | the specific intent to set |
| void PdfPainter::SetShadingPattern | ( | const PdfShadingPattern & | pattern | ) |
Set the shading pattern for all following non-stroking operations. This operation uses the 'scn' PDF operator.
| rPattern | a shading pattern |
| void PdfPainter::SetStrokeStyle | ( | PdfStrokeStyle | strokeStyle, |
| const std::string_view & | custom = { }, |
||
| bool | inverted = false, |
||
| double | scale = 1.0, |
||
| bool | subtractJoinCap = false |
||
| ) |
Set the stoke style for all stroking operations.
| strokeStyle | style of the stroking operations |
| custom | a custom stroking style which is used when strokeStyle == PdfStrokeStyle::Custom. |
| inverted | inverted dash style (gaps for drawn spaces), it is ignored for None, Solid and Custom styles |
| scale | scale factor of the stroke style it is ignored for None, Solid and Custom styles |
| subtractJoinCap | if 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: PdfStrokeStyle::None PdfStrokeStyle::Solid PdfStrokeStyle::Dash PdfStrokeStyle::Dot PdfStrokeStyle::DashDot PdfStrokeStyle::DashDotDot PdfStrokeStyle::Custom
| void PdfPainter::SetStrokeWidth | ( | double | width | ) |
Set the line width for all stroking operations.
| width | in PDF User Units. |
| void PdfPainter::SetStrokingColor | ( | const PdfColor & | color | ) |
Set the color for all following stroking operations.
| color | a PdfColor object |
| void PdfPainter::SetStrokingShadingPattern | ( | const PdfShadingPattern & | pattern | ) |
Set the shading pattern for all following stroking operations. This operation uses the 'SCN' PDF operator.
| rPattern | a shading pattern |
| void PdfPainter::SetStrokingTilingPattern | ( | const PdfTilingPattern & | pattern | ) |
Set the tiling pattern for all following stroking operations. This operation uses the 'SCN' PDF operator.
| rPattern | a tiling pattern |
| void mm::PdfPainter::SetStrokingTilingPattern | ( | const std::string_view & | patternName | ) |
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.
| rPatternName | a tiling pattern name |
|
inline |
Set the tab width for the DrawText operation. Every tab '\t' is replaced with tabWidth spaces before drawing text. Default is a value of 4
| tabWidth | replace every tabulator by this much spaces |
| void PdfPainter::SetTextRenderingMode | ( | PdfTextRenderingMode | mode | ) |
Set the text rendering mode
| mode | What text rendering mode to use. |
Possible values: PdfTextRenderingMode::Fill (default mode) PdfTextRenderingMode::Stroke PdfTextRenderingMode::FillAndStroke PdfTextRenderingMode::Invisible PdfTextRenderingMode::FillToClipPath PdfTextRenderingMode::StrokeToClipPath PdfTextRenderingMode::FillAndStrokeToClipPath PdfTextRenderingMode::ToClipPath
| void PdfPainter::SetTilingPattern | ( | const PdfTilingPattern & | pattern | ) |
Set the tiling pattern for all following non-stroking operations. This operation uses the 'scn' PDF operator.
| rPattern | a tiling pattern |
| void PdfPainter::SetTilingPattern | ( | const std::string_view & | patternName | ) |
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.
| rPattern | a tiling pattern |
| void 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.
| a | scale in x direction |
| b | rotation |
| c | rotation |
| d | scale in y direction |
| e | translate in x direction |
| f | translate in y direction |
| void PdfPainter::SmoothCurveTo | ( | double | x2, |
| double | y2, | ||
| double | x3, | ||
| double | y3 | ||
| ) |
Append a smooth bezier curve to the current path Matches the SVG 'S' operator.
| x2 | x coordinate of the second control point |
| y2 | y coordinate of the second control point |
| x3 | x coordinate of the end point, which is the new current point |
| y3 | y coordinate of the end point, which is the new current point |
| void PdfPainter::SmoothQuadCurveTo | ( | double | x3, |
| double | y3 | ||
| ) |
Append a smooth quadratic bezier curve to the current path Matches the SVG 'T' operator.
| x3 | x coordinate of the end point, which is the new current point |
| y3 | y coordinate of the end point, which is the new current point |
| void PdfPainter::Stroke | ( | ) |
Stroke the current path. Matches the PDF 'S' operator. This function is useful to construct an own path for drawing or clipping.
| void PdfPainter::VerticalLineTo | ( | double | y | ) |
Append a vertical line to the current path Matches the SVG 'V' operator
| y | y coordinate to draw the line to |