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-2023 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
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 
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 
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 {
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 
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
void SetGamma(double exp)
void SetPathHinting(bool enable_hinting)
void SetClipRect(Rect clip_rect)
void SetPrintMode(bool is_printing)
void SetImageSmoothing(bool smoothing_enabled=true, bool hq_image_resampling=false)
void SetPageBox(Page::Box region)
PDFDraw(double dpi=92)
void SetThinLineScaling(double scaling)
TRN_UInt8 UInt8
Definition: BasicTypes.h:15
BitmapInfo(const BitmapInfo &b)
Definition: PDFDraw.h:51
void(* ErrorReportProc)(const char *message, void *data)
void SetPageTransparent(bool is_transparent)
void SetImageSize(int width, int height, bool preserve_aspect_ratio=true)
BitmapInfo(int w, int h, int s, double d, char *b)
Definition: PDFDraw.h:37
std::vector< Separation > GetSeparationBitmaps(Page page)
void SetRotate(Page::Rotate r)
void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b)
TRN_UChar UChar
Definition: BasicTypes.h:12
void SetFlipYAxis(bool flip_y)
void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void *data)
std::vector< unsigned char > GetBuffer() const
Definition: PDFDraw.h:60
void SetDPI(double dpi)
void Export(Page page, const UString &filename, const char *format="PNG", SDF::Obj encoder_params=0)
void SetRasterizerType(PDFRasterizer::Type type)
void SetCaching(bool enabled=true)
const BitmapInfo GetBitmap(Page page, PixelFormat pix_fmt=e_bgra, bool demult=false)
void SetDrawUIElements(bool draw_ui_elements)
void SetDrawAnnotations(bool render_annots)
void SetOCGContext(OCG::Context *ctx)
void SetColorPostProcessMode(PDFRasterizer::ColorPostProcessMode mode)
void SetHighlightFields(bool highlight_fields)
void SetAntiAliasing(bool enable_aa)
void SetThinLineAdjustment(bool pixel_grid_fit, bool stroke_adjust)
void SetOverprint(PDFRasterizer::OverprintPreviewMode op)
void DrawInRect(Page &page, void *hdc, const Rect &rect)