1 #ifndef EXTENSION_INTERNAL_PDF_CAIRO_H_SEEN
2 #define EXTENSION_INTERNAL_PDF_CAIRO_H_SEEN
4 /** \file
5 * Declaration of PrintCairoPDF, the internal module used to do PDF printing with Cairo.
6 */
7 /*
8 * Authors:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 * Ted Gould <ted@gould.cx>
11 *
12 * Lauris' original code is in the public domain.
13 * Ted's changes are licensed under the GNU GPL.
14 */
16 #include <config.h>
17 #include "extension/extension.h"
18 #include "extension/implementation/implementation.h"
19 #include <set>
20 #include <string>
22 #include "libnr/nr-path.h"
23 #include "libnrtype/font-instance.h"
25 #include "svg/stringstream.h"
26 #include "sp-gradient.h"
28 #include "cairo.h"
29 #include <pango/pangocairo.h>
31 namespace Inkscape {
32 namespace Extension {
33 namespace Internal {
35 class PrintCairoPDF : public Inkscape::Extension::Implementation::Implementation {
36 float _width;
37 float _height;
38 FILE *_stream;
39 cairo_t *cr;
40 cairo_surface_t *pdf_surface;
41 PangoLayout *_layout;
42 // PangoContext *_context;
43 float *_alpha_stack;
44 int _num_alphas, _alpha_ptr;
45 double _last_tx, _last_ty;
47 unsigned short _dpi;
48 bool _bitmap;
50 void print_bpath(cairo_t *cr, NArtBpath const *bp);
51 cairo_pattern_t *create_pattern_for_paint(SPPaintServer const *const paintserver, NRRect const *pbox, float alpha);
53 void print_fill_style(cairo_t *cr, SPStyle const *const style, NRRect const *pbox);
54 void print_stroke_style(cairo_t *cr, SPStyle const *style, NRRect const *pbox);
56 #ifndef USE_PANGO_CAIRO
57 NR::Point draw_glyphs(cairo_t *cr, NR::Point p, PangoFont *font, PangoGlyphString *glyph_string,
58 bool vertical, bool stroke);
59 #endif
61 public:
62 PrintCairoPDF(void);
63 virtual ~PrintCairoPDF(void);
65 /* Print functions */
66 virtual unsigned int setup(Inkscape::Extension::Print *module);
67 /*
68 virtual unsigned int set_preview(Inkscape::Extension::Print *module);
69 */
71 virtual unsigned int begin(Inkscape::Extension::Print *module, SPDocument *doc);
72 virtual unsigned int finish(Inkscape::Extension::Print *module);
74 /* Rendering methods */
75 virtual unsigned int bind(Inkscape::Extension::Print *module, NRMatrix const *transform, float opacity);
76 virtual unsigned int release(Inkscape::Extension::Print *module);
77 virtual unsigned int comment(Inkscape::Extension::Print *module, char const *comment);
78 virtual unsigned int fill(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *ctm, SPStyle const *style,
79 NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
80 virtual unsigned int stroke(Inkscape::Extension::Print *module, NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style,
81 NRRect const *pbox, NRRect const *dbox, NRRect const *bbox);
82 virtual unsigned int image(Inkscape::Extension::Print *module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
83 NRMatrix const *transform, SPStyle const *style);
84 virtual unsigned int text(Inkscape::Extension::Print *module, char const *text,
85 NR::Point p, SPStyle const *style);
87 bool textToPath(Inkscape::Extension::Print *ext);
88 static void init(void);
89 };
91 } /* namespace Internal */
92 } /* namespace Extension */
93 } /* namespace Inkscape */
96 #endif /* !EXTENSION_INTERNAL_PDF_CAIRO_H_SEEN */
98 /*
99 Local Variables:
100 mode:c++
101 c-file-style:"stroustrup"
102 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103 indent-tabs-mode:nil
104 fill-column:99
105 End:
106 */
107 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :