Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::Extension::Internal::PdfBuilder::Document Class Reference

#include <build-document.h>

Public Member Functions

 Document (char const *filename, capypdf::DocumentProperties &opt)
 
void add_page (PageContext &page)
 
void set_label (uint32_t page, std::string const &label)
 
void write ()
 
void set_filter_resolution (unsigned res=0)
 
unsigned get_filter_resolution () const
 
void set_text_enabled (bool enabled)
 
bool get_text_enabled () const
 
std::optional< CapyPDF_TransparencyGroupId > add_group (ItemContext &context)
 
std::optional< CapyPDF_TransparencyGroupId > item_to_transparency_group (SPItem const *item, SPStyle const *context_style=nullptr, bool is_soft_mask=false)
 Render any type of item into a transparency group.
 
std::optional< CapyPDF_TransparencyGroupId > mask_to_transparency_group (SPMask const *mask, Geom::Affine const &transform)
 Render a mask out to a transparency group context.
 
std::optional< CapyPDF_TransparencyGroupId > style_to_transparency_mask (SPStyle const *style, SPStyle const *context_style)
 Render gradient transparencies into a transparency mask.
 
std::optional< CapyPDF_GraphicsStateId > get_group_graphics_state (SPStyle const *style, std::optional< CapyPDF_TransparencyGroupId > sm)
 Set the style for any graphic from the SVG style.
 
std::optional< CapyPDF_GraphicsStateId > get_shape_graphics_state (SPStyle const *style)
 Like get_graphics_style but for drawing shapes (paths)
 
std::optional< CapyPDF_FontId > get_font (std::string const &filename)
 Load a font and cache the results.
 
std::optional< capypdf::Color > get_paint (SPIPaint const &paint, SPStyle const *context_style, std::optional< double > opacity)
 Generate a solid color, gradient or pattern based on the SPIPaint.
 
capypdf::Color get_color (Colors::Color const &color, std::optional< double > opacity)
 
std::optional< CapyPDF_PatternId > get_pattern (SPPaintServer const *paint, std::optional< double > opacity)
 Construct a PDF pattern object from the given paintserver.
 
CapyPDF_Device_Colorspace get_default_colorspace () const
 
CapyPDF_Device_Colorspace get_colorspace (std::shared_ptr< Colors::Space::AnySpace > const &space) const
 
std::optional< CapyPDF_IccColorSpaceId > get_icc_profile (std::shared_ptr< Colors::Space::CMS > const &profile)
 

Protected Member Functions

capypdf::Generator & generator ()
 
StyleMemorypaint_memory ()
 
std::vector< CapyPDF_AnnotationId > get_anchors_for_page (SPPage const *page)
 Load an anchor link and add it to the page.
 

Private Member Functions

std::optional< CapyPDF_PatternId > get_linear_pattern (SPLinearGradient const *linear, std::optional< double > opacity)
 Generate a linear gradient or linear gradient mask.
 
std::optional< CapyPDF_PatternId > get_radial_pattern (SPRadialGradient const *radial, std::optional< double > opacity)
 Generate a radial gradient or radial gradient mask.
 
std::optional< CapyPDF_PatternId > get_mesh_pattern (SPMeshGradient const *mesh, std::optional< double > opacity)
 Generate a mesh gradient or mesh gradient mask.
 
std::optional< CapyPDF_PatternId > get_tiling_pattern (SPPattern const *pat, Geom::Affine const &transform)
 Render a pattern out to a transparency group context.
 
std::optional< CapyPDF_FunctionId > get_gradient_function (SPGradientVector const &vector, std::optional< double > opacity, CapyPDF_Device_Colorspace *space)
 Generate a non-continous gradient from the gradient vector and add to the document.
 
std::optional< CapyPDF_FunctionId > get_repeat_function (CapyPDF_FunctionId gradient, bool reflected, int from, int to)
 Generate a type3 gradient function which repeats the given gradient for the given ranges.
 

Private Attributes

capypdf::Generator _gen
 
StyleMemory _paint_memory
 
std::map< std::string, CapyPDF_IccColorSpaceId > _icc_cache
 
std::map< ItemCacheKey, CapyPDF_TransparencyGroupId > _item_cache
 
std::map< std::string, CapyPDF_TransparencyGroupId > _mask_cache
 
std::map< std::string, CapyPDF_PatternId > _pattern_cache
 
std::map< std::string, CapyPDF_FontId > _font_cache
 
std::set< SPAnchor const * > _anchors
 
unsigned _filter_resolution = 0
 
bool _text_enabled = true
 

Friends

class DrawContext
 
class PageContext
 
class GroupContext
 
class PatternContext
 
class TextContext
 

Detailed Description

Definition at line 81 of file build-document.h.

Constructor & Destructor Documentation

◆ Document()

Inkscape::Extension::Internal::PdfBuilder::Document::Document ( char const *  filename,
capypdf::DocumentProperties &  opt 
)
inline

Member Function Documentation

◆ add_group()

◆ add_page()

void Inkscape::Extension::Internal::PdfBuilder::Document::add_page ( PageContext page)

Definition at line 52 of file build-document.cpp.

References _gen, and page.

◆ generator()

capypdf::Generator & Inkscape::Extension::Internal::PdfBuilder::Document::generator ( )
inlineprotected

◆ get_anchors_for_page()

std::vector< CapyPDF_AnnotationId > Inkscape::Extension::Internal::PdfBuilder::Document::get_anchors_for_page ( SPPage const *  page)
protected

Load an anchor link and add it to the page.

  • page - Limit the anchors to just this page.
  • page_tr - The transformation in the PDF used to place the anchor's box.

Definition at line 229 of file build-document.cpp.

References _anchors, _gen, SPObject::document, Inkscape::PageManager::getPageFor(), SPDocument::getPageManager(), SPItem::i2doc_affine(), item, page, Inkscape::Extension::Internal::PdfBuilder::PageContext::page_transform(), result, and SPItem::visualBounds().

Referenced by Inkscape::Extension::Internal::PdfBuilder::PageContext::add_anchors_for_page().

◆ get_color()

capypdf::Color Inkscape::Extension::Internal::PdfBuilder::Document::get_color ( Colors::Color const &  color,
std::optional< double >  opacity 
)

◆ get_colorspace()

CapyPDF_Device_Colorspace Inkscape::Extension::Internal::PdfBuilder::Document::get_colorspace ( std::shared_ptr< Colors::Space::AnySpace > const &  space) const

◆ get_default_colorspace()

CapyPDF_Device_Colorspace Inkscape::Extension::Internal::PdfBuilder::Document::get_default_colorspace ( ) const

Definition at line 386 of file build-styles.cpp.

Referenced by get_linear_pattern(), get_mesh_pattern(), and get_radial_pattern().

◆ get_filter_resolution()

unsigned Inkscape::Extension::Internal::PdfBuilder::Document::get_filter_resolution ( ) const
inline

◆ get_font()

std::optional< CapyPDF_FontId > Inkscape::Extension::Internal::PdfBuilder::Document::get_font ( std::string const &  filename)

Load a font and cache the results.

Parameters
filename- The filename to the font to use.
Returns
the FontId in capypdf to use.

Definition at line 289 of file build-styles.cpp.

References _font_cache, _gen, and Inkscape::Extension::Internal::err().

Referenced by Inkscape::Extension::Internal::PdfBuilder::TextContext::set_text_style().

◆ get_gradient_function()

std::optional< CapyPDF_FunctionId > Inkscape::Extension::Internal::PdfBuilder::Document::get_gradient_function ( SPGradientVector const &  vector,
std::optional< double >  opacity,
CapyPDF_Device_Colorspace *  pdf_space 
)
private

Generate a non-continous gradient from the gradient vector and add to the document.

Returns
The FunctionId for the new gradient and sets the pdf_space Color Space if needed.

Definition at line 359 of file build-patterns.cpp.

References _gen, bounds, get_color(), get_colorspace(), and SPGradientVector::stops.

Referenced by get_linear_pattern(), and get_radial_pattern().

◆ get_group_graphics_state()

std::optional< CapyPDF_GraphicsStateId > Inkscape::Extension::Internal::PdfBuilder::Document::get_group_graphics_state ( SPStyle const *  style,
std::optional< CapyPDF_TransparencyGroupId >  soft_mask 
)

Set the style for any graphic from the SVG style.

Parameters
style- The SPStyle for this SPObject
Returns
A GraphicsStateId for the object added to the document, or none if none is needed.

Definition at line 219 of file build-styles.cpp.

References _gen, Inkscape::Extension::Internal::PdfBuilder::get_blendmode(), SPStyle::mix_blend_mode, and SPStyle::opacity.

Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_group().

◆ get_icc_profile()

std::optional< CapyPDF_IccColorSpaceId > Inkscape::Extension::Internal::PdfBuilder::Document::get_icc_profile ( std::shared_ptr< Colors::Space::CMS > const &  profile)

Definition at line 368 of file build-styles.cpp.

References _gen, _icc_cache, and key.

Referenced by get_color().

◆ get_linear_pattern()

std::optional< CapyPDF_PatternId > Inkscape::Extension::Internal::PdfBuilder::Document::get_linear_pattern ( SPLinearGradient const *  linear,
std::optional< double >  opacity 
)
private

Generate a linear gradient or linear gradient mask.

  • linear - The Linear Gradient object to paint into the PDF Document
  • opacity - If set, generate the linear gradient mask instead of the color gradient
Returns
A PDF Id of the new gradient object in the PDF document, if created.

Definition at line 139 of file build-patterns.cpp.

References _gen, get_default_colorspace(), get_gradient_function(), Inkscape::Extension::Internal::PdfBuilder::get_id(), get_repeat_function(), linear(), Inkscape::Extension::Internal::PdfBuilder::repeat_is_reflection(), and SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX.

Referenced by get_pattern().

◆ get_mesh_pattern()

std::optional< CapyPDF_PatternId > Inkscape::Extension::Internal::PdfBuilder::Document::get_mesh_pattern ( SPMeshGradient const *  mesh,
std::optional< double >  opacity 
)
private

Generate a mesh gradient or mesh gradient mask.

  • mesh - The Mesh Gradient object to paint into the PDF Document
  • opacity - If set, generate the mesh gradient mask instead of the color gradient
Returns
A PDF Id of the new gradient object in the PDF document, if created.

Definition at line 269 of file build-patterns.cpp.

References _gen, get_color(), get_colorspace(), get_default_colorspace(), Inkscape::Extension::Internal::PdfBuilder::get_id(), SPGradient::getAllItemsBox(), SPGradient::gradientTransform, SPMeshNodeArray::nodes, SPMeshNodeArray::patch_columns(), SPMeshNodeArray::patch_rows(), and SPMeshNodeArray::read().

Referenced by get_pattern().

◆ get_paint()

std::optional< capypdf::Color > Inkscape::Extension::Internal::PdfBuilder::Document::get_paint ( SPIPaint const &  paint,
SPStyle const *  context_style,
std::optional< double >  opacity 
)

◆ get_pattern()

std::optional< CapyPDF_PatternId > Inkscape::Extension::Internal::PdfBuilder::Document::get_pattern ( SPPaintServer const *  paint,
std::optional< double >  opacity 
)

Construct a PDF pattern object from the given paintserver.

Gradients or patterns.

  • paint - The paint server vector.
  • bbox - The bounding box for this pattern
  • opacity - The total paint opacity, used for softmasking. Only used for soft-masking

Definition at line 91 of file build-patterns.cpp.

References _pattern_cache, Inkscape::Extension::Internal::PdfBuilder::get_id(), get_linear_pattern(), get_mesh_pattern(), get_radial_pattern(), get_tiling_pattern(), SPPatternReference::getObject(), SPPaintServer::isValid(), linear(), and SPPattern::ref.

Referenced by get_paint().

◆ get_radial_pattern()

std::optional< CapyPDF_PatternId > Inkscape::Extension::Internal::PdfBuilder::Document::get_radial_pattern ( SPRadialGradient const *  radial,
std::optional< double >  opacity 
)
private

◆ get_repeat_function()

std::optional< CapyPDF_FunctionId > Inkscape::Extension::Internal::PdfBuilder::Document::get_repeat_function ( CapyPDF_FunctionId  gradient,
bool  reflected,
int  from,
int  to 
)
private

Generate a type3 gradient function which repeats the given gradient for the given ranges.

Definition at line 410 of file build-patterns.cpp.

References _gen, and bounds.

Referenced by get_linear_pattern(), and get_radial_pattern().

◆ get_shape_graphics_state()

std::optional< CapyPDF_GraphicsStateId > Inkscape::Extension::Internal::PdfBuilder::Document::get_shape_graphics_state ( SPStyle const *  style)

Like get_graphics_style but for drawing shapes (paths)

Parameters
style- The style from the SPObject
Returns
the GraphicsStateId for the object added to the document, or none if not needed.

Definition at line 255 of file build-styles.cpp.

References _gen, SPStyle::fill_opacity, SPStyle::stroke_opacity, and style_to_transparency_mask().

Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item().

◆ get_text_enabled()

bool Inkscape::Extension::Internal::PdfBuilder::Document::get_text_enabled ( ) const
inline

◆ get_tiling_pattern()

std::optional< CapyPDF_PatternId > Inkscape::Extension::Internal::PdfBuilder::Document::get_tiling_pattern ( SPPattern const *  pat,
Geom::Affine const &  transform 
)
private

◆ item_to_transparency_group()

std::optional< CapyPDF_TransparencyGroupId > Inkscape::Extension::Internal::PdfBuilder::Document::item_to_transparency_group ( SPItem const *  item,
SPStyle const *  context_style = nullptr,
bool  is_soft_mask = false 
)

◆ mask_to_transparency_group()

std::optional< CapyPDF_TransparencyGroupId > Inkscape::Extension::Internal::PdfBuilder::Document::mask_to_transparency_group ( SPMask const *  mask,
Geom::Affine const &  transform 
)

◆ paint_memory()

StyleMemory & Inkscape::Extension::Internal::PdfBuilder::Document::paint_memory ( )
inlineprotected

◆ set_filter_resolution()

void Inkscape::Extension::Internal::PdfBuilder::Document::set_filter_resolution ( unsigned  res = 0)
inline

Definition at line 104 of file build-document.h.

References _filter_resolution.

◆ set_label()

void Inkscape::Extension::Internal::PdfBuilder::Document::set_label ( uint32_t  page,
std::string const &  label 
)

Definition at line 47 of file build-document.cpp.

References _gen, label, and page.

◆ set_text_enabled()

void Inkscape::Extension::Internal::PdfBuilder::Document::set_text_enabled ( bool  enabled)
inline

Definition at line 107 of file build-document.h.

References _text_enabled.

◆ style_to_transparency_mask()

std::optional< CapyPDF_TransparencyGroupId > Inkscape::Extension::Internal::PdfBuilder::Document::style_to_transparency_mask ( SPStyle const *  style,
SPStyle const *  context_style 
)

◆ write()

void Inkscape::Extension::Internal::PdfBuilder::Document::write ( )
inline

Definition at line 102 of file build-document.h.

References _gen.

Friends And Related Symbol Documentation

◆ DrawContext

friend class DrawContext
friend

Definition at line 146 of file build-document.h.

◆ GroupContext

friend class GroupContext
friend

Definition at line 148 of file build-document.h.

◆ PageContext

friend class PageContext
friend

Definition at line 147 of file build-document.h.

◆ PatternContext

friend class PatternContext
friend

Definition at line 149 of file build-document.h.

◆ TextContext

friend class TextContext
friend

Definition at line 150 of file build-document.h.

Member Data Documentation

◆ _anchors

std::set<SPAnchor const *> Inkscape::Extension::Internal::PdfBuilder::Document::_anchors
private

Definition at line 171 of file build-document.h.

Referenced by get_anchors_for_page(), and item_to_transparency_group().

◆ _filter_resolution

unsigned Inkscape::Extension::Internal::PdfBuilder::Document::_filter_resolution = 0
private

Definition at line 173 of file build-document.h.

Referenced by get_filter_resolution(), and set_filter_resolution().

◆ _font_cache

std::map<std::string, CapyPDF_FontId> Inkscape::Extension::Internal::PdfBuilder::Document::_font_cache
private

Definition at line 168 of file build-document.h.

Referenced by get_font().

◆ _gen

◆ _icc_cache

std::map<std::string, CapyPDF_IccColorSpaceId> Inkscape::Extension::Internal::PdfBuilder::Document::_icc_cache
private

Definition at line 164 of file build-document.h.

Referenced by get_icc_profile().

◆ _item_cache

std::map<ItemCacheKey, CapyPDF_TransparencyGroupId> Inkscape::Extension::Internal::PdfBuilder::Document::_item_cache
private

Definition at line 165 of file build-document.h.

Referenced by add_group(), and item_to_transparency_group().

◆ _mask_cache

std::map<std::string, CapyPDF_TransparencyGroupId> Inkscape::Extension::Internal::PdfBuilder::Document::_mask_cache
private

Definition at line 166 of file build-document.h.

Referenced by mask_to_transparency_group().

◆ _paint_memory

StyleMemory Inkscape::Extension::Internal::PdfBuilder::Document::_paint_memory
private

Definition at line 162 of file build-document.h.

Referenced by get_tiling_pattern(), paint_memory(), and style_to_transparency_mask().

◆ _pattern_cache

std::map<std::string, CapyPDF_PatternId> Inkscape::Extension::Internal::PdfBuilder::Document::_pattern_cache
private

Definition at line 167 of file build-document.h.

Referenced by get_pattern().

◆ _text_enabled

bool Inkscape::Extension::Internal::PdfBuilder::Document::_text_enabled = true
private

Definition at line 174 of file build-document.h.

Referenced by get_text_enabled(), and set_text_enabled().


The documentation for this class was generated from the following files: