- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
27 namespace pdftron {
28 namespace PDF {
29
30
31 //return type for PDFDraw::GetBitmap
32 class BitmapInfo
33 {
34 std::vector<unsigned char> buf;
35
36 public:
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
51 BitmapInfo(const BitmapInfo& b) {
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
65 class Separation;
66
74 class PDFDraw
75 {
76 public:
77
85 PDFDraw(double dpi = 92);
86 ~PDFDraw();
87
99 void SetRasterizerType (PDFRasterizer::Type type);
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
170 void SetRotate(Page::Rotate r);
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
285 void SetOCGContext(OCG::Context* ctx);
286
296 void SetPrintMode(bool is_printing);
297
310 void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b);
311
326 void SetPageTransparent(bool is_transparent);
327
337 void SetOverprint(PDFRasterizer::OverprintPreviewMode op);
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
469 enum PixelFormat {
470 e_rgba,
471 e_bgra,
472 e_rgb,
473 e_bgr,
474 e_gray,
475 e_gray_alpha,
476 e_cmyk
477 };
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
511
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
548 void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void* data);
549 #endif
550
560 void SetColorPostProcessMode(PDFRasterizer::ColorPostProcessMode mode);
561
565 void Destroy();
566
567 // @cond PRIVATE_DOC
568 #ifndef SWIGHIDDEN
569 TRN_PDFDraw mp_draw;
570 #endif
571 private:
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
pdftron::PDF::PDFDraw::SetGamma
void SetGamma(double exp)
pdftron::PDF::PDFDraw::SetPathHinting
void SetPathHinting(bool enable_hinting)
pdftron::PDF::PDFDraw::SetClipRect
void SetClipRect(Rect clip_rect)
pdftron::PDF::PDFDraw::SetPrintMode
void SetPrintMode(bool is_printing)
pdftron::PDF::PDFDraw::SetImageSmoothing
void SetImageSmoothing(bool smoothing_enabled=true, bool hq_image_resampling=false)
pdftron::PDF::PDFDraw::SetPageBox
void SetPageBox(Page::Box region)
pdftron::PDF::PDFDraw::e_gray
Definition: PDFDraw.h:474
pdftron::PDF::PDFDraw::PixelFormat
PixelFormat
Definition: PDFDraw.h:469
pdftron::PDF::PDFDraw
Definition: PDFDraw.h:74
pdftron::PDF::PDFDraw::e_bgr
Definition: PDFDraw.h:473
pdftron::PDF::PDFDraw::PDFDraw
PDFDraw(double dpi=92)
pdftron::PDF::OCG::Context
Definition: Context.h:41
pdftron::PDF::PDFDraw::SetThinLineScaling
void SetThinLineScaling(double scaling)
pdftron::PDF::PDFDraw::e_bgra
Definition: PDFDraw.h:471
pdftron::UInt8
TRN_UInt8 UInt8
Definition: BasicTypes.h:15
pdftron::PDF::PDFRasterizer::ColorPostProcessMode
ColorPostProcessMode
Definition: PDFRasterizer.h:461
pdftron::PDF::PDFDraw::~PDFDraw
~PDFDraw()
pdftron::PDF::BitmapInfo::BitmapInfo
BitmapInfo(const BitmapInfo &b)
Definition: PDFDraw.h:51
pdftron::PDF::Rect
Definition: Rect.h:28
pdftron::PDF::BitmapInfo::dpi
double dpi
Definition: PDFDraw.h:48
pdftron::PDF::BitmapInfo::stride
int stride
Definition: PDFDraw.h:47
Callback.h
pdftron::PDF::PDFRasterizer::ErrorReportProc
void(* ErrorReportProc)(const char *message, void *data)
Definition: PDFRasterizer.h:423
pdftron::PDF::Page::Rotate
Rotate
Definition: Page.h:190
pdftron::PDF::PDFDraw::SetPageTransparent
void SetPageTransparent(bool is_transparent)
pdftron::PDF::Page::Box
Box
Definition: Page.h:98
pdftron::PDF::PDFDraw::SetImageSize
void SetImageSize(int width, int height, bool preserve_aspect_ratio=true)
pdftron::PDF::BitmapInfo::BitmapInfo
BitmapInfo(int w, int h, int s, double d, char *b)
Definition: PDFDraw.h:37
pdftron::PDF::PDFDraw::e_rgba
Definition: PDFDraw.h:470
pdftron::PDF::PDFDraw::Destroy
void Destroy()
pdftron::PDF::PDFDraw::GetSeparationBitmaps
std::vector< Separation > GetSeparationBitmaps(Page page)
pdftron::PDF::PDFDraw::SetRotate
void SetRotate(Page::Rotate r)
pdftron::PDF::PDFRasterizer::OverprintPreviewMode
OverprintPreviewMode
Definition: PDFRasterizer.h:114
pdftron::PDF::PDFDraw::SetDefaultPageColor
void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b)
pdftron::UChar
TRN_UChar UChar
Definition: BasicTypes.h:12
pdftron::PDF::PDFDraw::SetFlipYAxis
void SetFlipYAxis(bool flip_y)
pdftron::Filters::Filter
Definition: Filter.h:45
pdftron::PDF::PDFDraw::SetErrorReportProc
void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void *data)
pdftron::PDF::BitmapInfo::GetBuffer
std::vector< unsigned char > GetBuffer() const
Definition: PDFDraw.h:60
pdftron::PDF::PDFDraw::SetDPI
void SetDPI(double dpi)
pdftron::PDF::PDFDraw::Export
void Export(Page page, const UString &filename, const char *format="PNG", SDF::Obj encoder_params=0)
pdftron::PDF::PDFDraw::SetRasterizerType
void SetRasterizerType(PDFRasterizer::Type type)
pdftron::PDF::PDFDraw::SetCaching
void SetCaching(bool enabled=true)
pdftron::PDF::Page
Definition: Page.h:31
pdftron::PDF::PDFDraw::e_gray_alpha
Definition: PDFDraw.h:475
pdftron::PDF::PDFDraw::GetBitmap
const BitmapInfo GetBitmap(Page page, PixelFormat pix_fmt=e_bgra, bool demult=false)
pdftron::PDF::PDFDraw::SetDrawUIElements
void SetDrawUIElements(bool draw_ui_elements)
pdftron::PDF::PDFDraw::SetDrawAnnotations
void SetDrawAnnotations(bool render_annots)
pdftron::PDF::BitmapInfo::width
int width
Definition: PDFDraw.h:45
pdftron::PDF::BitmapInfo::height
int height
Definition: PDFDraw.h:46
pdftron::PDF::PDFDraw::SetOCGContext
void SetOCGContext(OCG::Context *ctx)
pdftron::PDF::PDFDraw::SetColorPostProcessMode
void SetColorPostProcessMode(PDFRasterizer::ColorPostProcessMode mode)
pdftron::PDF::PDFDraw::SetHighlightFields
void SetHighlightFields(bool highlight_fields)
pdftron::PDF::PDFDraw::SetAntiAliasing
void SetAntiAliasing(bool enable_aa)
pdftron::PDF::PDFDraw::e_cmyk
Definition: PDFDraw.h:476
pdftron::SDF::Obj
Definition: Obj.h:40
pdftron::PDF::PDFDraw::SetThinLineAdjustment
void SetThinLineAdjustment(bool pixel_grid_fit, bool stroke_adjust)
pdftron::PDF::PDFRasterizer::Type
Type
Definition: PDFRasterizer.h:103
pdftron::PDF::BitmapInfo
Definition: PDFDraw.h:32
PDFRasterizer.h
pdftron::PDF::PDFDraw::e_rgb
Definition: PDFDraw.h:472
pdftron::UString
Definition: UString.h:27
pdftron::PDF::PDFDraw::SetOverprint
void SetOverprint(PDFRasterizer::OverprintPreviewMode op)
pdftron::PDF::PDFDraw::DrawInRect
void DrawInRect(Page &page, void *hdc, const Rect &rect)