Loading...
Searching...
No Matches
PDFDraw.h
Go to the documentation of this file.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2025 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5#ifndef PDFTRON_H_CPPPDFPDFDraw
6#define PDFTRON_H_CPPPDFPDFDraw
7
8#include <PDF/PDFRasterizer.h>
9#include <C/PDF/TRN_PDFDraw.h>
10
11#ifdef SWIG
12#include <PDF/Callback.h>
13#endif
14
15// @cond PRIVATE_DOC
16#ifndef SWIGHIDDEN
17#if defined(_WIN32)
18 // A forward declaration for GDI+ Bitmap-s which can be directly created using PDFDraw::GetBitmap() method.
19 namespace Gdiplus { class Bitmap; };
20#endif
21#endif
22// @endcond
23
24
25
26
27namespace pdftron {
28 namespace PDF {
29
30
31//return type for PDFDraw::GetBitmap
33{
34 std::vector<unsigned char> buf;
35
36public:
37 BitmapInfo(int w, int h, int s, double d, char* b) {
38 width = w;
39 height = h;
40 stride = s;
41 dpi = d;
42 buf.resize(h*s);
43 memcpy(&buf[0], b, h*s);
44 }
45 int width;
46 int height;
47 int stride;
48 double dpi;
49
50 //copy constructor
52 width = b.width;
53 height = b.height;
54 stride = b.stride;
55 dpi = b.dpi;
56 std::vector<unsigned char> temp(b.GetBuffer());
57 buf.swap(temp);
58 }
59
60 std::vector<unsigned char> GetBuffer() const {
61 return buf;
62 }
63};
64
65class Separation;
66
75{
76public:
77
85 PDFDraw(double dpi = 92);
87
100
121 void SetDPI(double dpi);
122
135 void SetImageSize(int width, int height, bool preserve_aspect_ratio = true);
136
143 void SetPageBox(Page::Box region);
144
151 void SetClipRect(Rect clip_rect);
152
159 void SetFlipYAxis(bool flip_y);
160
171
178 void SetDrawAnnotations(bool render_annots);
179
185 void SetHighlightFields(bool highlight_fields);
186
192 void SetDrawUIElements(bool draw_ui_elements);
193
203 void SetAntiAliasing(bool enable_aa);
204
213 void SetPathHinting(bool enable_hinting);
214
225 void SetThinLineAdjustment(bool pixel_grid_fit, bool stroke_adjust);
226
236 void SetThinLineScaling(double scaling);
237
252 void SetImageSmoothing(bool smoothing_enabled = true, bool hq_image_resampling = false);
253
260 void SetCaching(bool enabled = true);
261
274 void SetGamma(double exp);
275
286
296 void SetPrintMode(bool is_printing);
297
311
326 void SetPageTransparent(bool is_transparent);
327
338
422 void Export(Page page, const UString& filename, const char* format = "PNG", SDF::Obj encoder_params = 0);
423
432 void Export(Page page, Filters::Filter& stream, const char* format = "PNG", SDF::Obj encoder_params = 0);
433
442 #ifdef __DOTNET
443 System::Drawing::Bitmap* GetBitmap(Page page);
444 #endif
445
462#if defined(_WIN32) && !defined(__WINRT__)
463 void DrawInRect(Page& page, void* hdc, const Rect& rect);
464#endif
465
478
494 const BitmapInfo GetBitmap(Page page, PixelFormat pix_fmt = e_bgra, bool demult = false);
495
508 std::vector<Separation> GetSeparationBitmaps(Page page);
509
510#ifndef SWIG
534 const UChar* GetBitmap(Page page, int& out_width, int& out_height, int& out_stride, double& out_dpi,
535 PixelFormat pix_fmt = e_bgra, bool demult = false);
536#endif
537
545#ifdef SWIG
546 void SetErrorReportProc(Callback* instance);
547#else
549#endif
550
561
565 void Destroy();
566
567// @cond PRIVATE_DOC
568#ifndef SWIGHIDDEN
569 TRN_PDFDraw mp_draw;
570#endif
571private:
572 // PDFDraw should not be copied
573 PDFDraw(const PDFDraw& other);
574 PDFDraw& operator= (const PDFDraw&);
575// @endcond
576};
577
578
579#include <Impl/PDFDraw.inl>
580
581
582 }; // namespace PDF
583}; // namespace pdftron
584
585#endif // PDFTRON_H_CPPPDFPDFDraw
std::vector< unsigned char > GetBuffer() const
Definition PDFDraw.h:60
BitmapInfo(const BitmapInfo &b)
Definition PDFDraw.h:51
BitmapInfo(int w, int h, int s, double d, char *b)
Definition PDFDraw.h:37
void SetPageBox(Page::Box region)
void Export(Page page, const UString &filename, const char *format="PNG", SDF::Obj encoder_params=0)
void SetOverprint(PDFRasterizer::OverprintPreviewMode op)
void SetCaching(bool enabled=true)
void SetImageSize(int width, int height, bool preserve_aspect_ratio=true)
void SetAntiAliasing(bool enable_aa)
void SetHighlightFields(bool highlight_fields)
void SetPageTransparent(bool is_transparent)
void SetFlipYAxis(bool flip_y)
void SetImageSmoothing(bool smoothing_enabled=true, bool hq_image_resampling=false)
void Export(Page page, Filters::Filter &stream, const char *format="PNG", SDF::Obj encoder_params=0)
void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void *data)
void SetOCGContext(OCG::Context *ctx)
void SetDPI(double dpi)
void SetDrawUIElements(bool draw_ui_elements)
void SetGamma(double exp)
void SetRasterizerType(PDFRasterizer::Type type)
void SetThinLineScaling(double scaling)
const BitmapInfo GetBitmap(Page page, PixelFormat pix_fmt=e_bgra, bool demult=false)
void SetPathHinting(bool enable_hinting)
PDFDraw(double dpi=92)
void SetDrawAnnotations(bool render_annots)
std::vector< Separation > GetSeparationBitmaps(Page page)
void SetClipRect(Rect clip_rect)
void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b)
void SetPrintMode(bool is_printing)
void SetColorPostProcessMode(PDFRasterizer::ColorPostProcessMode mode)
void SetRotate(Page::Rotate r)
void SetThinLineAdjustment(bool pixel_grid_fit, bool stroke_adjust)
const UChar * GetBitmap(Page page, int &out_width, int &out_height, int &out_stride, double &out_dpi, PixelFormat pix_fmt=e_bgra, bool demult=false)
void(* ErrorReportProc)(const char *message, void *data)
TRN_UInt8 UInt8
Definition BasicTypes.h:15
TRN_UChar UChar
Definition BasicTypes.h:12