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-2018 by PDFTron Systems 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 
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 
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 
72 class PDFDraw
73 {
74 public:
75 
83  PDFDraw(double dpi = 92);
84  ~PDFDraw();
85 
95 
116  void SetDPI(double dpi);
117 
130  void SetImageSize(int width, int height, bool preserve_aspect_ratio = true);
131 
138  void SetPageBox(Page::Box region);
139 
146  void SetClipRect(Rect clip_rect);
147 
154  void SetFlipYAxis(bool flip_y);
155 
165  void SetRotate(Page::Rotate r);
166 
173  void SetDrawAnnotations(bool render_annots);
174 
180  void SetHighlightFields(bool highlight_fields);
181 
191  void SetAntiAliasing(bool enable_aa);
192 
201  void SetPathHinting(bool enable_hinting);
202 
213  void SetThinLineAdjustment(bool pixel_grid_fit, bool stroke_adjust);
214 
229  void SetImageSmoothing(bool smoothing_enabled = true, bool hq_image_resampling = false);
230 
237  void SetCaching(bool enabled = true);
238 
251  void SetGamma(double exp);
252 
262  void SetOCGContext(OCG::Context* ctx);
263 
273  void SetPrintMode(bool is_printing);
274 
287  void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b);
288 
303  void SetPageTransparent(bool is_transparent);
304 
315 
399  void Export(Page page, const UString& filename, const char* format = "PNG", SDF::Obj encoder_params = 0);
400 
409  void Export(Page page, Filters::Filter& stream, const char* format = "PNG", SDF::Obj encoder_params = 0);
410 
419  #ifdef __DOTNET
420  System::Drawing::Bitmap* GetBitmap(Page page);
421  #endif
422 
435 #if defined(_WIN32) && !defined(__WINRT__)
436  void DrawInRect(Page& page, void* hdc, const Rect& rect);
437 #endif
438 
442  enum PixelFormat {
450  };
451 
475  const BitmapInfo GetBitmap(Page page, PixelFormat pix_fmt = e_bgra, bool demult = false);
476 
477 #ifndef SWIG
478  const UChar* GetBitmap(Page page, int& out_width, int& out_height, int& out_stride, double& out_dpi,
479  PixelFormat pix_fmt = e_bgra, bool demult = false);
480 #endif
481 
489 #ifdef SWIG
490  void SetErrorReportProc(Callback* instance);
491 #else
492  void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void* data);
493 #endif
494 
505 
509  void Destroy();
510 
512 #ifndef SWIGHIDDEN
513  TRN_PDFDraw mp_draw;
514 #endif
515 private:
516  // PDFDraw should not be copied
517  PDFDraw(const PDFDraw& other);
518  PDFDraw& operator= (const PDFDraw&);
520 };
521 
522 
523 #include <Impl/PDFDraw.inl>
524 
525 
526  }; // namespace PDF
527 }; // namespace pdftron
528 
529 #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)
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
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 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)

© 2002-2014 PDFTron Systems Inc.