1 | // |
2 | // Page.h |
3 | // |
4 | // Library: PDF |
5 | // Package: PDFCore |
6 | // Module: Page |
7 | // |
8 | // Definition of the Page class. |
9 | // |
10 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef PDF_Page_INCLUDED |
18 | #define PDF_Page_INCLUDED |
19 | |
20 | |
21 | #include "Poco/PDF/PDF.h" |
22 | #include "Poco/PDF/Resource.h" |
23 | #include "Poco/PDF/Font.h" |
24 | #include "Poco/PDF/Image.h" |
25 | #include "Poco/PDF/Encoder.h" |
26 | #include "Poco/PDF/Destination.h" |
27 | #include "Poco/PDF/TextAnnotation.h" |
28 | #include "Poco/PDF/LinkAnnotation.h" |
29 | #include "Poco/Exception.h" |
30 | #include <map> |
31 | |
32 | |
33 | namespace Poco { |
34 | namespace PDF { |
35 | |
36 | |
37 | class Document; |
38 | |
39 | |
40 | class PDF_API Page |
41 | /// A Page represents a PDF page object. |
42 | { |
43 | public: |
44 | typedef HPDF_Page Type; |
45 | typedef std::map<std::string, Destination> DestinationContainer; |
46 | typedef std::map<std::string, TextAnnotation> TextAnnotationContainer; |
47 | typedef std::map<std::string, LinkAnnotation> LinkAnnotationContainer; |
48 | |
49 | enum Size |
50 | { |
51 | PAGE_SIZE_LETTER = HPDF_PAGE_SIZE_LETTER, |
52 | /// 8½ x 11 (Inches), 612 x 792 px |
53 | PAGE_SIZE_LEGAL = HPDF_PAGE_SIZE_LEGAL, |
54 | /// 8½ x 14 (Inches), 612 x 1008 px |
55 | PAGE_SIZE_A3 = HPDF_PAGE_SIZE_A3, |
56 | /// 297 × 420 (mm), 841.89 x 1199.551 px |
57 | PAGE_SIZE_A4 = HPDF_PAGE_SIZE_A4, |
58 | /// 210 × 297 (mm), 595.276 x 841.89 px |
59 | PAGE_SIZE_A5 = HPDF_PAGE_SIZE_A5, |
60 | /// 148 × 210 (mm), 419.528 x 595.276 px |
61 | PAGE_SIZE_B4 = HPDF_PAGE_SIZE_B4, |
62 | /// 250 × 353 (mm), 708.661 x 1000.63 px |
63 | PAGE_SIZE_B5 = HPDF_PAGE_SIZE_B5, |
64 | /// 176 × 250 (mm), 498.898 x 708.661 px |
65 | PAGE_SIZE_EXECUTIVE = HPDF_PAGE_SIZE_EXECUTIVE, |
66 | /// 7½ x 10½ (Inches), 522 x 756 px |
67 | PAGE_SIZE_US4x6 = HPDF_PAGE_SIZE_US4x6, |
68 | /// 4 x 6 (Inches), 288 x 432 px |
69 | PAGE_SIZE_US4x8 = HPDF_PAGE_SIZE_US4x8, |
70 | /// 4 x 8 (Inches), 288 x 576 px |
71 | PAGE_SIZE_US5x7 = HPDF_PAGE_SIZE_US5x7, |
72 | /// 5 x 7 (Inches), 360 x 504 px |
73 | PAGE_SIZE_COMM10 = HPDF_PAGE_SIZE_COMM10 |
74 | /// 4.125 x 9.5 (Inches) 297x 684 px |
75 | }; |
76 | |
77 | enum Orientation |
78 | { |
79 | ORIENTATION_PORTRAIT = HPDF_PAGE_PORTRAIT, |
80 | // Portrait orientation. |
81 | ORIENTATION_LANDSCAPE = HPDF_PAGE_LANDSCAPE |
82 | // Landscape orientation. |
83 | }; |
84 | |
85 | enum RenderMode |
86 | { |
87 | RENDER_FILL = HPDF_FILL, |
88 | RENDER_STROKE = HPDF_STROKE, |
89 | RENDER_FILL_THEN_STROKE = HPDF_FILL_THEN_STROKE, |
90 | RENDER_INVISIBLE = HPDF_INVISIBLE, |
91 | RENDER_FILL_CLIPPING = HPDF_FILL_CLIPPING, |
92 | RENDER_STROKE_CLIPPING = HPDF_STROKE_CLIPPING, |
93 | RENDER_FILL_STROKE_CLIPPING = HPDF_FILL_STROKE_CLIPPING, |
94 | RENDER_CLIPPING = HPDF_CLIPPING, |
95 | RENDER_RENDERING_MODE_EOF = HPDF_RENDERING_MODE_EOF |
96 | }; |
97 | |
98 | enum ColorSpace |
99 | { |
100 | CS_DEVICE_GRAY = HPDF_CS_DEVICE_GRAY, |
101 | CS_DEVICE_RGB = HPDF_CS_DEVICE_RGB, |
102 | CS_DEVICE_CMYK = HPDF_CS_DEVICE_CMYK, |
103 | CS_CAL_GRAY = HPDF_CS_CAL_GRAY, |
104 | CS_CAL_RGB = HPDF_CS_CAL_RGB, |
105 | CS_LAB = HPDF_CS_LAB, |
106 | CS_ICC_BASED = HPDF_CS_ICC_BASED, |
107 | CS_SEPARATION = HPDF_CS_SEPARATION, |
108 | CS_DEVICE_N = HPDF_CS_DEVICE_N, |
109 | CS_INDEXED = HPDF_CS_INDEXED, |
110 | CS_PATTERN = HPDF_CS_PATTERN, |
111 | CS_EOF = HPDF_CS_EOF |
112 | }; |
113 | |
114 | enum TransitionStyle |
115 | { |
116 | TS_WIPE_RIGHT = HPDF_TS_WIPE_RIGHT, |
117 | TS_WIPE_UP = HPDF_TS_WIPE_UP, |
118 | TS_WIPE_LEFT = HPDF_TS_WIPE_LEFT, |
119 | TS_WIPE_DOWN = HPDF_TS_WIPE_DOWN, |
120 | TS_BARN_DOORS_HORIZONTAL_OUT = HPDF_TS_BARN_DOORS_HORIZONTAL_OUT, |
121 | TS_BARN_DOORS_HORIZONTAL_IN = HPDF_TS_BARN_DOORS_HORIZONTAL_IN, |
122 | TS_BARN_DOORS_VERTICAL_OUT = HPDF_TS_BARN_DOORS_VERTICAL_OUT, |
123 | TS_BARN_DOORS_VERTICAL_IN = HPDF_TS_BARN_DOORS_VERTICAL_IN, |
124 | TS_BOX_OUT = HPDF_TS_BOX_OUT, |
125 | TS_BOX_IN = HPDF_TS_BOX_IN, |
126 | TS_BLINDS_HORIZONTAL = HPDF_TS_BLINDS_HORIZONTAL, |
127 | TS_BLINDS_VERTICAL = HPDF_TS_BLINDS_VERTICAL, |
128 | TS_DISSOLVE = HPDF_TS_DISSOLVE, |
129 | TS_GLITTER_RIGHT = HPDF_TS_GLITTER_RIGHT, |
130 | TS_GLITTER_DOWN = HPDF_TS_GLITTER_DOWN, |
131 | TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT = HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT, |
132 | TS_REPLACE = HPDF_TS_REPLACE |
133 | }; |
134 | |
135 | enum TextAlignment |
136 | { |
137 | TEXT_ALIGN_LEFT = HPDF_TALIGN_LEFT, |
138 | /// The text is aligned to left. |
139 | TEXT_ALIGN_RIGHT = HPDF_TALIGN_RIGHT, |
140 | /// The text is aligned to right. |
141 | TEXT_ALIGN_CENTER = HPDF_TALIGN_CENTER, |
142 | /// The text is aligned to center. |
143 | TEXT_ALIGN_JUSTIFY = HPDF_TALIGN_JUSTIFY |
144 | /// Add spaces between the words to justify both left and right side. |
145 | }; |
146 | |
147 | Page(Document* pDocument, |
148 | const HPDF_Page& page, |
149 | Size pageSize = PAGE_SIZE_LETTER, |
150 | Orientation orientation = ORIENTATION_PORTRAIT); |
151 | /// Creates the page |
152 | |
153 | Page(const Page& other); |
154 | /// Copy creates the page. |
155 | |
156 | virtual ~Page(); |
157 | /// Destroys the page. |
158 | |
159 | Page& operator = (const Page& page); |
160 | /// Assignment operator. |
161 | |
162 | operator const Type& () const; |
163 | /// Const conversion operator into reference to native type. |
164 | |
165 | bool operator == (const Page& other) const; |
166 | /// Equality operator. |
167 | |
168 | void swap(Page& other); |
169 | /// Swaps this page with another. |
170 | |
171 | void setWidth(float value); |
172 | /// Sets the page width. |
173 | |
174 | float getWidth() const; |
175 | /// Gets the page width. |
176 | |
177 | void setHeight(float value); |
178 | /// Sets the page height. |
179 | |
180 | float getHeight() const; |
181 | /// Gets the page height. |
182 | |
183 | void setSize(Size size); |
184 | /// Sets the page size. |
185 | |
186 | Size getSize() const; |
187 | /// Returns the page size. |
188 | |
189 | void setOrientation(Orientation orientation); |
190 | /// Sets the page orientation. |
191 | |
192 | Orientation getOrientation() const; |
193 | /// Returns the page orientation. |
194 | |
195 | void setSizeAndOrientation(Size size, Orientation orientation); |
196 | /// Sets the page size and orientation. |
197 | |
198 | void setRotation(int angle); |
199 | /// Sets the rotation for the page. |
200 | /// Angle must be multiple of 90. |
201 | |
202 | void setFont(const Font& font, float size); |
203 | /// Sets the font. |
204 | |
205 | void setFont(const std::string& fontName, float size, const std::string& encoding = "" ); |
206 | /// Sets the font. The name must be a valid Base14 PDF internal font. |
207 | |
208 | void setTTFont(const std::string& name, float size, const std::string& encoding = "UTF-8" , bool embed = true); |
209 | /// Sets the external true type font. Name must be a valid path to .ttf file. |
210 | /// If embed is tru, font will be embedded int othe document. |
211 | |
212 | float textWidth(const std::string& text); |
213 | /// Returns the width of the supplied text. |
214 | |
215 | void beginText(); |
216 | /// Begins a text object and sets the current text position to the point (0,0). |
217 | |
218 | void endText(); |
219 | /// Ends a text object. |
220 | |
221 | void write(float xPos, float yPos, const std::string& text); |
222 | /// Write text at specified position. |
223 | |
224 | void writeOnce(float xPos, float yPos, const std::string& text); |
225 | /// Begins, writes and ends text object. |
226 | |
227 | void write(const std::string& text); |
228 | /// Writes the text at the current position on the page. |
229 | |
230 | void writeNextLine(const std::string& text); |
231 | /// Moves the current text position to the start of the next line and |
232 | /// prints the text at the current position on the page. |
233 | |
234 | void writeNextLineEx(float wordSpace, float charSpace, const std::string& text); |
235 | /// Moves the current text position to the start of the next line, sets the word spacing, |
236 | /// character spacing and prints the text at the current position on the page. |
237 | |
238 | int writeOnceInRectangle(float left, |
239 | float top, |
240 | float right, |
241 | float bottom, |
242 | const std::string& text, |
243 | TextAlignment align = TEXT_ALIGN_LEFT); |
244 | /// Begins, writes and ends text objectinside the specified region. |
245 | /// Returns the number of characters written. |
246 | |
247 | int writeInRectangle(float left, |
248 | float top, |
249 | float right, |
250 | float bottom, |
251 | const std::string& text, |
252 | TextAlignment align); |
253 | /// Writes the text inside the specified region. |
254 | /// Returns the number of characters written. |
255 | |
256 | void drawImage(Image image, float x, float y, float width, float height); |
257 | /// Draws an image in one operation. |
258 | |
259 | const Destination& createDestination(const std::string& name); |
260 | /// Creates ad returns reference to destination. |
261 | |
262 | const TextAnnotation& createTextAnnotation(const std::string& name, |
263 | const Rectangle& rect, |
264 | const std::string& text, |
265 | const Encoder& encoder); |
266 | /// Creates ad returns reference to text annotation. |
267 | |
268 | const LinkAnnotation& createLinkAnnotation(const std::string& name, |
269 | const Rectangle& rect, |
270 | const Destination& dest); |
271 | /// Creates ad returns reference to destination link annotation. |
272 | |
273 | const LinkAnnotation& createURILinkAnnotation(const std::string& name, |
274 | const Rectangle& rect, |
275 | const std::string& uri); |
276 | /// Creates ad returns reference to URI annotation. |
277 | |
278 | int getGraphicsMode() const; |
279 | /// Returns current graphics mode. |
280 | |
281 | int getGraphicStateDepth() const; |
282 | /// Returns current graphics mode. |
283 | |
284 | void setExtGraphicsState(ExtGraphicsState state); |
285 | /// Sets the graphic state. |
286 | |
287 | void saveGraphics(); |
288 | /// Pushes graphics parameters on the stack. |
289 | |
290 | void restoreGraphics(); |
291 | /// Restores graphics parameters from the stack. |
292 | |
293 | void concatenate(const std::vector<float>& values); |
294 | /// Concatenates the page's current transformation matrix and specified matrix. |
295 | |
296 | void moveTo(float x, float y); |
297 | /// Starts a new subpath and move the current point for drawing path. |
298 | /// Sets the start point for the path to the point (x, y). |
299 | |
300 | void lineTo(float x, float y); |
301 | /// Appends a path from the current point to the specified point.. |
302 | |
303 | void curveTo(const std::vector<float>& values); |
304 | /// Appends a Bézier curve to the current path using two specified points. |
305 | /// The point (x1, y1) and the point (x2, y2) are used as the control points |
306 | /// for a Bézier curve and current point is moved to the point (x3, y3) |
307 | |
308 | void curveToRight(float x2, float y2, float x3, float y3); |
309 | /// Appends a Bézier curve to the right of the current point using two specified points. |
310 | /// The current point and the point (x2, y2) are used as the control points |
311 | /// for a Bézier curve and current point is moved to the point (x3, y3) |
312 | |
313 | void curveToLeft(float x2, float y2, float x3, float y3); |
314 | /// Appends a Bézier curve to the left of the current point using two specified points. |
315 | /// The current point and the point (x2, y2) are used as the control points |
316 | /// for a Bézier curve and current point is moved to the point (x3, y3) |
317 | |
318 | void closePath(); |
319 | /// Appends a straight line from the current point to the start point of sub path. |
320 | /// The current point is moved to the start point of sub path. |
321 | |
322 | void rectangle(float x, float y, float width, float height); |
323 | /// Draws a rectangle. |
324 | |
325 | void circle(float x, float y, float radius); |
326 | /// Draws a circle. |
327 | |
328 | void arc(float x, float y, float radius, float beginAngle, float endAngle); |
329 | /// Draws an arc. |
330 | |
331 | void ellipse(float x, float y, float xRadius, float yRadius); |
332 | /// Draws an ellips. |
333 | |
334 | void stroke(); |
335 | /// Paints the current path. |
336 | |
337 | void closeAndStroke(); |
338 | /// Closes the current path and paints it. |
339 | |
340 | void fill(); |
341 | /// Fills the current path using the nonzero winding number rule. |
342 | |
343 | void EOFill(); |
344 | /// Fills the current path using the even-odd rule. |
345 | |
346 | void fillStroke(); |
347 | /// Fills the current path using the nonzero winding number rule and then paints it. |
348 | |
349 | void EOFillStroke(); |
350 | /// Fills the current path using the even-odd rule and then paints it. |
351 | |
352 | void closeFillAndStroke(); |
353 | /// Closes the current path, fills the current path using the nonzero winding number |
354 | /// rule and then paints it. |
355 | |
356 | void closeFillAndEOStroke(); |
357 | /// Closes the current path, fills the current path using the even-odd rule and then paints it. |
358 | |
359 | void endPath(); |
360 | /// Ends the path object without filling and painting operation. |
361 | |
362 | void clip(); |
363 | /// |
364 | |
365 | void eoClip(); |
366 | /// |
367 | |
368 | Point getPos() const; |
369 | /// Returns the current position. |
370 | |
371 | Point getTextPos() const; |
372 | /// Returns the current position for text showing. |
373 | |
374 | void moveTextPos(float x, float y); |
375 | /// Moves the current text position to the start of the next line |
376 | /// using specified offset values. If the start position of the current |
377 | /// line is (x1, y1), the start of the next line is (x1 + x, y1 + y). |
378 | |
379 | void moveTextNextLine(float x, float y); |
380 | /// Moves the current text position to the start of the next line |
381 | /// using specified offset values, and sets the text leading to -y. |
382 | /// If the start position of the current line is (x1, y1), the start |
383 | /// of the next line is (x1 + x, y1 + y). |
384 | |
385 | void moveTextNextLine(); |
386 | /// Moves the current text position to the start of the next line. |
387 | /// If the start position of the current line is (x1, y1), the start of |
388 | /// the next line is (x1, y1 - text leading). |
389 | /// |
390 | /// NOTE: |
391 | /// Since the default value of Text Leading is 0, an application has to |
392 | /// invoke HPDF_Page_SetTextLeading() before HPDF_Page_MoveTextPos2() to set |
393 | /// text leading. |
394 | |
395 | const Font& getFont() const; |
396 | /// Returns the current font. |
397 | |
398 | float getFontSize() const; |
399 | /// Returns the current Font size. |
400 | |
401 | TransMatrix getTransMatrix() const; |
402 | /// Returns the current transformation matrix. |
403 | |
404 | TransMatrix getTextMatrix() const; |
405 | /// Returns the current text transformation matrix. |
406 | |
407 | float getLineWidth() const; |
408 | /// Returns the current line width. |
409 | |
410 | void setLineWidth(float width); |
411 | /// Sets the line width. |
412 | |
413 | LineCap getLineCap() const; |
414 | /// Returns the current line cap. |
415 | |
416 | void setLineCap(LineCap cap) const; |
417 | /// Sets the line cap. |
418 | |
419 | LineJoin getLineJoin() const; |
420 | /// Returns the current line join. |
421 | |
422 | void setLineJoin(LineJoin join) const; |
423 | /// Returns the current line join. |
424 | |
425 | float getMiterLimit() const; |
426 | /// Returns the current miter limit. |
427 | |
428 | void setMiterLimit(float limit) const; |
429 | /// Sets the miter limit. |
430 | |
431 | DashMode getDashMode() const; |
432 | /// Returns current dash mode. |
433 | |
434 | void setDashMode(const PatternVec& pattern, int paramNo, int phase) const; |
435 | /// Sets teh dash mode. |
436 | |
437 | float getFlatness() const; |
438 | /// Returns the current flatness. |
439 | |
440 | float getCharSpace() const; |
441 | /// Returns the current character space. |
442 | |
443 | void setCharSpace(float value); |
444 | /// Sets the current character space. |
445 | |
446 | float getWordSpace() const; |
447 | /// Returns the current word space. |
448 | |
449 | void setWordSpace(float value); |
450 | /// Sets the current word space. |
451 | |
452 | float getHorizontalScale() const; |
453 | /// Returns the current horizontal scaling. |
454 | |
455 | void setHorizontalScale(float value); |
456 | /// Sets the current horizontal scaling. |
457 | |
458 | float getTextLead() const; |
459 | /// Returns the current text leading. |
460 | |
461 | void setTextLead(float value); |
462 | /// Sets the current text leading. |
463 | |
464 | RenderMode getTextRenderMode() const; |
465 | /// Returns the current text rendering mode. |
466 | |
467 | void setTextRenderMode(RenderMode value); |
468 | /// Sets the current text rendering mode. |
469 | |
470 | float getTextRise() const; |
471 | /// Returns the current text leading. |
472 | |
473 | void setTextRise(float value); |
474 | /// Sets the current text leading. |
475 | |
476 | RGBColor getRGBFill() const; |
477 | /// Returns current RGB fill. |
478 | |
479 | void setRGBFill(RGBColor value); |
480 | /// Sets current RGB fill. |
481 | |
482 | RGBColor getRGBStroke() const; |
483 | /// Returns current RGB stroke. |
484 | |
485 | void setRGBStroke(RGBColor value); |
486 | /// Sets current RGB stroke. |
487 | |
488 | CMYKColor getCMYKFill() const; |
489 | /// Returns current CMYK fill. |
490 | |
491 | void setCMYKFill(CMYKColor value); |
492 | /// Sets current CMYK fill. |
493 | |
494 | CMYKColor getCMYKStroke() const; |
495 | /// Returns current CMYK stroke. |
496 | |
497 | void setCMYKStroke(CMYKColor value); |
498 | /// Returns current CMYK stroke. |
499 | |
500 | float getGreyFill() const; |
501 | /// Returns current grey fill. |
502 | |
503 | void setGreyFill(float value); |
504 | /// Sets current grey fill. |
505 | |
506 | float getGreyStroke() const; |
507 | /// Returns current grey stroke. |
508 | |
509 | void setGreyStroke(float value); |
510 | /// Sets current grey stroke. |
511 | |
512 | ColorSpace getStrokeColorSpace() const; |
513 | /// Returns current stroking color space. |
514 | |
515 | ColorSpace getFillColorSpace() const; |
516 | /// Returns current filling color space. |
517 | |
518 | void setSlideShow(TransitionStyle type, float displayTime, float transitionTime); |
519 | /// Configures the setting for slide transition of the page |
520 | |
521 | private: |
522 | Page(); |
523 | |
524 | Document* _pDocument; |
525 | HPDF_Page _page; |
526 | Size _size; |
527 | Orientation _orientation; |
528 | DestinationContainer _destinations; |
529 | TextAnnotationContainer _textAnnotations; |
530 | LinkAnnotationContainer _linkAnnotations; |
531 | mutable Font* _pCurrentFont; |
532 | }; |
533 | |
534 | |
535 | // |
536 | // inlines |
537 | // |
538 | |
539 | |
540 | inline Page::operator const Page::Type& () const |
541 | { |
542 | return _page; |
543 | } |
544 | |
545 | |
546 | inline void Page::setWidth(float value) |
547 | { |
548 | HPDF_Page_SetWidth(_page, value); |
549 | } |
550 | |
551 | |
552 | inline float Page::getWidth() const |
553 | { |
554 | return HPDF_Page_GetWidth(_page); |
555 | } |
556 | |
557 | |
558 | inline void Page::setHeight(float value) |
559 | { |
560 | HPDF_Page_SetHeight(_page, value); |
561 | } |
562 | |
563 | |
564 | inline float Page::getHeight() const |
565 | { |
566 | return HPDF_Page_GetHeight(_page); |
567 | } |
568 | |
569 | |
570 | inline void Page::setSizeAndOrientation(Size size, Orientation orientation) |
571 | { |
572 | _size = size; |
573 | _orientation = orientation; |
574 | HPDF_Page_SetSize(_page, static_cast<HPDF_PageSizes>(size), static_cast<HPDF_PageDirection>(orientation)); |
575 | } |
576 | |
577 | |
578 | inline void Page::setSize(Size size) |
579 | { |
580 | _size = size; |
581 | HPDF_Page_SetSize(_page, static_cast<HPDF_PageSizes>(size), static_cast<HPDF_PageDirection>(_orientation)); |
582 | } |
583 | |
584 | |
585 | inline void Page::setOrientation(Orientation orientation) |
586 | { |
587 | _orientation = orientation; |
588 | HPDF_Page_SetSize(_page, static_cast<HPDF_PageSizes>(_size), static_cast<HPDF_PageDirection>(orientation)); |
589 | } |
590 | |
591 | |
592 | inline Page::Size Page::getSize() const |
593 | { |
594 | return _size; |
595 | } |
596 | |
597 | |
598 | inline Page::Orientation Page::getOrientation() const |
599 | { |
600 | return _orientation; |
601 | } |
602 | |
603 | |
604 | inline void Page::setFont(const Font& font, float size) |
605 | { |
606 | HPDF_Page_SetFontAndSize(_page, font, size); |
607 | } |
608 | |
609 | |
610 | inline int Page::getGraphicsMode() const |
611 | { |
612 | return HPDF_Page_GetGMode(_page); |
613 | } |
614 | |
615 | |
616 | inline int Page::getGraphicStateDepth() const |
617 | { |
618 | return HPDF_Page_GetGStateDepth(_page); |
619 | } |
620 | |
621 | |
622 | inline void Page::setExtGraphicsState(ExtGraphicsState state) |
623 | { |
624 | HPDF_Page_SetExtGState(_page, state); |
625 | } |
626 | |
627 | |
628 | inline void Page::saveGraphics() |
629 | { |
630 | HPDF_Page_GSave(_page); |
631 | } |
632 | |
633 | |
634 | inline void Page::restoreGraphics() |
635 | { |
636 | HPDF_Page_GRestore(_page); |
637 | } |
638 | |
639 | |
640 | inline void Page::concatenate(const std::vector<float>& values) |
641 | { |
642 | if (values.size() < 6) |
643 | throw InvalidArgumentException("Needs six values" ); |
644 | |
645 | HPDF_Page_Concat(_page, |
646 | values[0], |
647 | values[1], |
648 | values[2], |
649 | values[3], |
650 | values[4], |
651 | values[5]); |
652 | } |
653 | |
654 | |
655 | inline void Page::moveTo(float x, float y) |
656 | { |
657 | HPDF_Page_MoveTo(_page, x, y); |
658 | } |
659 | |
660 | |
661 | inline void Page::lineTo(float x, float y) |
662 | { |
663 | HPDF_Page_LineTo(_page, x, y); |
664 | } |
665 | |
666 | |
667 | inline void Page::curveTo(const std::vector<float>& values) |
668 | { |
669 | if (values.size() < 6) |
670 | throw InvalidArgumentException("Needs six values" ); |
671 | |
672 | HPDF_Page_CurveTo(_page, |
673 | values[0], |
674 | values[1], |
675 | values[2], |
676 | values[3], |
677 | values[4], |
678 | values[5]); |
679 | } |
680 | |
681 | |
682 | inline void Page::curveToRight(float x2, float y2, float x3, float y3) |
683 | { |
684 | HPDF_Page_CurveTo2(_page, x2, y2, x3, y3); |
685 | } |
686 | |
687 | |
688 | inline void Page::curveToLeft(float x2, float y2, float x3, float y3) |
689 | { |
690 | HPDF_Page_CurveTo3(_page, x2, y2, x3, y3); |
691 | } |
692 | |
693 | |
694 | inline void Page::closePath() |
695 | { |
696 | HPDF_Page_ClosePath(_page); |
697 | } |
698 | |
699 | |
700 | inline void Page::rectangle(float x, float y, float width, float height) |
701 | { |
702 | HPDF_Page_Rectangle(_page, x, y, width, height); |
703 | } |
704 | |
705 | |
706 | inline void Page::stroke() |
707 | { |
708 | HPDF_Page_Stroke(_page); |
709 | } |
710 | |
711 | |
712 | inline void Page::closeAndStroke() |
713 | { |
714 | HPDF_Page_ClosePathStroke(_page); |
715 | } |
716 | |
717 | |
718 | inline void Page::fill() |
719 | { |
720 | HPDF_Page_Fill(_page); |
721 | } |
722 | |
723 | |
724 | inline void Page::EOFill() |
725 | { |
726 | HPDF_Page_Eofill(_page); |
727 | } |
728 | |
729 | |
730 | inline void Page::fillStroke() |
731 | { |
732 | HPDF_Page_FillStroke(_page); |
733 | } |
734 | |
735 | |
736 | inline void Page::EOFillStroke() |
737 | { |
738 | HPDF_Page_EofillStroke(_page); |
739 | } |
740 | |
741 | |
742 | inline void Page::closeFillAndStroke() |
743 | { |
744 | HPDF_Page_ClosePathFillStroke(_page); |
745 | } |
746 | |
747 | |
748 | inline void Page::closeFillAndEOStroke() |
749 | { |
750 | HPDF_Page_ClosePathEofillStroke(_page); |
751 | } |
752 | |
753 | |
754 | inline void Page::endPath() |
755 | { |
756 | HPDF_Page_EndPath(_page); |
757 | } |
758 | |
759 | |
760 | inline void Page::clip() |
761 | { |
762 | HPDF_Page_Clip(_page); |
763 | } |
764 | |
765 | |
766 | inline void Page::eoClip() |
767 | { |
768 | HPDF_Page_Eoclip(_page); |
769 | } |
770 | |
771 | |
772 | inline Point Page::getPos() const |
773 | { |
774 | return HPDF_Page_GetCurrentPos(_page); |
775 | } |
776 | |
777 | |
778 | inline Point Page::getTextPos() const |
779 | { |
780 | return HPDF_Page_GetCurrentTextPos(_page); |
781 | } |
782 | |
783 | |
784 | inline void Page::moveTextPos(float x, float y) |
785 | { |
786 | HPDF_Page_MoveTextPos(_page, x, y); |
787 | } |
788 | |
789 | |
790 | inline void Page::moveTextNextLine(float x, float y) |
791 | { |
792 | HPDF_Page_MoveTextPos2(_page, x, y); |
793 | } |
794 | |
795 | |
796 | inline void Page::moveTextNextLine() |
797 | { |
798 | HPDF_Page_MoveToNextLine(_page); |
799 | } |
800 | |
801 | |
802 | inline float Page::getFontSize() const |
803 | { |
804 | return HPDF_Page_GetCurrentFontSize(_page); |
805 | } |
806 | |
807 | |
808 | inline TransMatrix Page::getTransMatrix() const |
809 | { |
810 | return HPDF_Page_GetTransMatrix(_page); |
811 | } |
812 | |
813 | |
814 | inline TransMatrix Page::getTextMatrix() const |
815 | { |
816 | return HPDF_Page_GetTextMatrix(_page); |
817 | } |
818 | |
819 | |
820 | inline float Page::getLineWidth() const |
821 | { |
822 | return HPDF_Page_GetLineWidth(_page); |
823 | } |
824 | |
825 | |
826 | inline void Page::setLineWidth(float width) |
827 | { |
828 | HPDF_Page_SetLineWidth(_page, width); |
829 | } |
830 | |
831 | |
832 | inline LineCap Page::getLineCap() const |
833 | { |
834 | return HPDF_Page_GetLineCap(_page); |
835 | } |
836 | |
837 | |
838 | inline void Page::setLineCap(LineCap cap) const |
839 | { |
840 | HPDF_Page_SetLineCap(_page, cap); |
841 | } |
842 | |
843 | |
844 | inline LineJoin Page::getLineJoin() const |
845 | { |
846 | return HPDF_Page_GetLineJoin(_page); |
847 | } |
848 | |
849 | |
850 | inline void Page::setLineJoin(LineJoin join) const |
851 | { |
852 | HPDF_Page_SetLineJoin(_page, join); |
853 | } |
854 | |
855 | |
856 | inline float Page::getMiterLimit() const |
857 | { |
858 | return HPDF_Page_GetMiterLimit(_page); |
859 | } |
860 | |
861 | |
862 | inline void Page::setMiterLimit(float limit) const |
863 | { |
864 | HPDF_Page_SetMiterLimit(_page, limit); |
865 | } |
866 | |
867 | |
868 | inline DashMode Page::getDashMode() const |
869 | { |
870 | return HPDF_Page_GetDash(_page); |
871 | } |
872 | |
873 | |
874 | inline void Page::setDashMode(const PatternVec& pattern, int paramNo, int phase) const |
875 | { |
876 | HPDF_Page_SetDash(_page, &pattern[0], |
877 | static_cast<HPDF_UINT>(paramNo), |
878 | static_cast<HPDF_UINT>(phase)); |
879 | } |
880 | |
881 | |
882 | inline float Page::getFlatness() const |
883 | { |
884 | return HPDF_Page_GetFlat(_page); |
885 | } |
886 | |
887 | |
888 | inline float Page::getCharSpace() const |
889 | { |
890 | return HPDF_Page_GetCharSpace(_page); |
891 | } |
892 | |
893 | |
894 | inline void Page::setCharSpace(float value) |
895 | { |
896 | HPDF_Page_SetCharSpace(_page, value); |
897 | } |
898 | |
899 | |
900 | inline float Page::getWordSpace() const |
901 | { |
902 | return HPDF_Page_GetWordSpace(_page); |
903 | } |
904 | |
905 | |
906 | inline void Page::setWordSpace(float value) |
907 | { |
908 | HPDF_Page_SetWordSpace(_page, value); |
909 | } |
910 | |
911 | |
912 | inline float Page::getHorizontalScale() const |
913 | { |
914 | return HPDF_Page_GetHorizontalScalling(_page); |
915 | } |
916 | |
917 | |
918 | inline void Page::setHorizontalScale(float value) |
919 | { |
920 | HPDF_Page_SetHorizontalScalling(_page, value); |
921 | } |
922 | |
923 | |
924 | inline float Page::getTextLead() const |
925 | { |
926 | return HPDF_Page_GetTextLeading(_page); |
927 | } |
928 | |
929 | |
930 | inline void Page::setTextLead(float value) |
931 | { |
932 | HPDF_Page_SetTextLeading(_page, value); |
933 | } |
934 | |
935 | |
936 | inline Page::RenderMode Page::getTextRenderMode() const |
937 | { |
938 | return static_cast<RenderMode>(HPDF_Page_GetTextRenderingMode(_page)); |
939 | } |
940 | |
941 | |
942 | inline void Page::setTextRenderMode(RenderMode value) |
943 | { |
944 | HPDF_Page_SetTextRenderingMode(_page, static_cast<HPDF_TextRenderingMode>(value)); |
945 | } |
946 | |
947 | |
948 | inline float Page::getTextRise() const |
949 | { |
950 | return HPDF_Page_GetTextRise(_page); |
951 | } |
952 | |
953 | |
954 | inline void Page::setTextRise(float value) |
955 | { |
956 | HPDF_Page_SetTextRise(_page, value); |
957 | } |
958 | |
959 | |
960 | inline RGBColor Page::getRGBFill() const |
961 | { |
962 | return HPDF_Page_GetRGBFill(_page); |
963 | } |
964 | |
965 | |
966 | inline void Page::setRGBFill(RGBColor value) |
967 | { |
968 | HPDF_Page_SetRGBFill(_page, value.r, value.g, value.b); |
969 | } |
970 | |
971 | |
972 | inline RGBColor Page::getRGBStroke() const |
973 | { |
974 | return HPDF_Page_GetRGBStroke(_page); |
975 | } |
976 | |
977 | |
978 | inline void Page::setRGBStroke(RGBColor value) |
979 | { |
980 | HPDF_Page_SetRGBStroke(_page, value.r, value.g, value.b); |
981 | } |
982 | |
983 | |
984 | inline CMYKColor Page::getCMYKFill() const |
985 | { |
986 | return HPDF_Page_GetCMYKFill(_page); |
987 | } |
988 | |
989 | |
990 | inline void Page::setCMYKFill(CMYKColor value) |
991 | { |
992 | HPDF_Page_SetCMYKFill(_page, value.c, value.m, value.y, value.k); |
993 | } |
994 | |
995 | |
996 | inline CMYKColor Page::getCMYKStroke() const |
997 | { |
998 | return HPDF_Page_GetCMYKStroke(_page); |
999 | } |
1000 | |
1001 | |
1002 | inline void Page::setCMYKStroke(CMYKColor value) |
1003 | { |
1004 | HPDF_Page_SetCMYKStroke(_page, value.c, value.m, value.y, value.k); |
1005 | } |
1006 | |
1007 | |
1008 | inline float Page::getGreyFill() const |
1009 | { |
1010 | return HPDF_Page_GetGrayFill(_page); |
1011 | } |
1012 | |
1013 | |
1014 | inline void Page::setGreyFill(float value) |
1015 | { |
1016 | HPDF_Page_SetGrayFill(_page, value); |
1017 | } |
1018 | |
1019 | |
1020 | inline float Page::getGreyStroke() const |
1021 | { |
1022 | return HPDF_Page_GetGrayStroke(_page); |
1023 | } |
1024 | |
1025 | |
1026 | inline void Page::setGreyStroke(float value) |
1027 | { |
1028 | HPDF_Page_SetGrayStroke(_page, value); |
1029 | } |
1030 | |
1031 | |
1032 | inline Page::ColorSpace Page::getStrokeColorSpace() const |
1033 | { |
1034 | return static_cast<ColorSpace>(HPDF_Page_GetStrokingColorSpace(_page)); |
1035 | } |
1036 | |
1037 | |
1038 | inline Page::ColorSpace Page::getFillColorSpace() const |
1039 | { |
1040 | return static_cast<ColorSpace>(HPDF_Page_GetFillingColorSpace(_page)); |
1041 | } |
1042 | |
1043 | |
1044 | inline void Page::setSlideShow(TransitionStyle type, float displayTime, float transitionTime) |
1045 | { |
1046 | HPDF_Page_SetSlideShow(_page, |
1047 | static_cast<HPDF_TransitionStyle>(type), |
1048 | displayTime, |
1049 | transitionTime); |
1050 | } |
1051 | |
1052 | |
1053 | inline void Page::beginText() |
1054 | { |
1055 | HPDF_Page_BeginText(_page); |
1056 | } |
1057 | |
1058 | inline void Page::endText() |
1059 | { |
1060 | HPDF_Page_EndText(_page); |
1061 | } |
1062 | |
1063 | |
1064 | inline void Page::write(float xPos, float yPos, const std::string& text) |
1065 | { |
1066 | HPDF_Page_TextOut(_page, xPos, yPos, text.c_str()); |
1067 | } |
1068 | |
1069 | |
1070 | inline void Page::write(const std::string& text) |
1071 | { |
1072 | HPDF_Page_ShowText(_page, text.c_str()); |
1073 | } |
1074 | |
1075 | |
1076 | inline void Page::writeNextLine(const std::string& text) |
1077 | { |
1078 | HPDF_Page_ShowTextNextLine(_page, text.c_str()); |
1079 | } |
1080 | |
1081 | |
1082 | inline void Page::writeNextLineEx(float wordSpace, float charSpace, const std::string& text) |
1083 | { |
1084 | HPDF_Page_ShowTextNextLineEx(_page, wordSpace, charSpace, text.c_str()); |
1085 | } |
1086 | |
1087 | |
1088 | inline int Page::writeInRectangle(float left, |
1089 | float top, |
1090 | float right, |
1091 | float bottom, |
1092 | const std::string& text, |
1093 | TextAlignment align) |
1094 | { |
1095 | HPDF_UINT ret = 0; |
1096 | HPDF_Page_TextRect(_page, |
1097 | left, |
1098 | top, |
1099 | right, |
1100 | bottom, |
1101 | text.c_str(), |
1102 | static_cast<HPDF_TextAlignment>(align), |
1103 | &ret); |
1104 | |
1105 | return static_cast<int>(ret); |
1106 | } |
1107 | |
1108 | |
1109 | inline void Page::drawImage(Image image, float x, float y, float width, float height) |
1110 | { |
1111 | HPDF_Page_DrawImage(_page, image, x, y, width, height); |
1112 | } |
1113 | |
1114 | |
1115 | inline void Page::circle(float x, float y, float radius) |
1116 | { |
1117 | HPDF_Page_Circle(_page, x, y, radius); |
1118 | } |
1119 | |
1120 | |
1121 | inline void Page::arc(float x, float y, float radius, float beginAngle, float endAngle) |
1122 | { |
1123 | HPDF_Page_Arc(_page, x, y, radius, beginAngle, endAngle); |
1124 | } |
1125 | |
1126 | |
1127 | inline void Page::ellipse(float x, float y, float xRadius, float yRadius) |
1128 | { |
1129 | HPDF_Page_Ellipse(_page, x, y, xRadius, yRadius); |
1130 | } |
1131 | |
1132 | |
1133 | } } // namespace Poco::PDF |
1134 | |
1135 | |
1136 | #endif // PDF_Page_INCLUDED |
1137 | |