00001
00002
00003
00004
00005
00006 #ifndef H_CPPPDFDraw
00007 #define H_CPPPDFDraw
00008
00009 #include <PDF/PDFRasterizer.h>
00010 #include <C/PDF/TRN_PDFDraw.h>
00011
00012 #ifdef SWIG
00013 #include <PDF/Callback.h>
00014 #endif
00015
00017 #ifndef SWIGHIDDEN
00018 #if defined(_WIN32) && !defined(WINCE)
00019
00020 namespace Gdiplus { class Bitmap; };
00021 #endif
00022 #endif
00024
00025
00026
00027
00028 namespace pdftron {
00029 namespace PDF {
00030
00031
00032
00033 class BitmapInfo
00034 {
00035 std::vector<unsigned char> buf;
00036
00037 public:
00038 BitmapInfo(int w, int h, int s, double d, char* b) {
00039 width = w;
00040 height = h;
00041 stride = s;
00042 dpi = d;
00043 buf.resize(h*s);
00044 memcpy(&buf[0], b, h*s);
00045 }
00046 int width;
00047 int height;
00048 int stride;
00049 double dpi;
00050
00051
00052 BitmapInfo(const BitmapInfo& b) {
00053 width = b.width;
00054 height = b.height;
00055 stride = b.stride;
00056 dpi = b.dpi;
00057 std::vector<unsigned char> temp(b.GetBuffer());
00058 buf.swap(temp);
00059 }
00060
00061 std::vector<unsigned char> GetBuffer() const {
00062 return buf;
00063 }
00064 };
00065
00073 class PDFDraw
00074 {
00075 public:
00076
00084 PDFDraw(double dpi = 92);
00085 ~PDFDraw();
00086
00095 void SetRasterizerType (PDFRasterizer::Type type);
00096
00116 void SetDPI(double dpi);
00117
00130 void SetImageSize(int width, int height, bool preserve_aspect_ratio = true);
00131
00138 void SetPageBox(Page::Box region);
00139
00146 void SetFlipYAxis(bool flip_y);
00147
00157 void SetRotate(Page::Rotate r);
00158
00165 void SetDrawAnnotations(bool render_annots);
00166
00172 void SetHighlightFields(bool highlight_fields);
00173
00183 void SetAntiAliasing(bool enable_aa);
00184
00193 void SetPathHinting(bool path_hinting);
00194
00205 void SetThinLineAdjustment(bool pixel_grid_fit, bool stroke_adjust);
00206
00220 void SetImageSmoothing(bool smoothing_enabled = true);
00221
00228 void SetCaching(bool enabled = true);
00229
00242 void SetGamma(double exp);
00243
00253 void SetOCGContext(OCG::Context* ctx);
00254
00264 void SetPrintMode(bool is_printing);
00265
00277 void SetDefaultPageColor(UInt8 r, UInt8 g, UInt8 b);
00278
00293 void SetPageTransparent(bool is_transparent);
00294
00304 void SetOverprint(PDFRasterizer::OverprintPreviewMode op);
00305
00385 void Export(Page page, const UString& filename, const char* format = "PNG", SDF::Obj encoder_params = 0);
00386
00395 #ifdef __DOTNET
00396 System::Drawing::Bitmap* GetBitmap(Page page);
00397 #endif
00398
00411 #ifdef _WIN32
00412 void DrawInRect(Page& page, void* hdc, const Rect& rect);
00413 #endif
00414
00418 enum PixelFormat {
00419 e_rgba,
00420 e_bgra,
00421 e_rgb,
00422 e_bgr,
00423 e_gray,
00424 e_gray_alpha,
00425 e_cmyk
00426 };
00427
00451 const BitmapInfo GetBitmap(Page page, PixelFormat pix_fmt = e_bgra, bool demult = false);
00452
00453 #ifndef SWIG
00454 const UChar* GetBitmap(Page page, int& out_width, int& out_height, int& out_stride, double& out_dpi,
00455 PixelFormat pix_fmt = e_bgra, bool demult = false);
00456 #endif
00457
00465 #ifdef SWIG
00466 void SetErrorReportProc(Callback* instance);
00467 #else
00468 void SetErrorReportProc(PDFRasterizer::ErrorReportProc error_proc, void* data);
00469 #endif
00470
00474 void Destroy();
00475
00477 #ifndef SWIGHIDDEN
00478 TRN_PDFDraw mp_draw;
00479 #endif
00481 };
00482
00483
00484 #include <Impl/PDFDraw.inl>
00485
00486
00487 };
00488 };
00489
00490
00491 #endif
00492
00493
00494