Foxit PDF SDK

fs_render.h
Go to the documentation of this file.
1
15 #ifndef FS_RENDER_H_
16 #define FS_RENDER_H_
17
18 #include "common/fs_common.h"
19 #include "common/fs_image.h"
20 #ifndef __EMSCRIPTEN_RENDER__
21 #include "pdf/annots/fs_annot.h"
22 #include "pdf/fs_pdflayer.h"
23 #include "pdf/fs_reflowpage.h"
24 #ifndef _FX_NO_XFA_
25 #include "addon/xfa/fs_xfa.h"
26 #endif // #ifndef _FX_NO_XFA_
27 #endif
28
29 #ifdef __APPLE__
30 #include <CoreGraphics/CoreGraphics.h>
31 #endif
32
37 namespace foxit {
38 namespace pdf {
39 class PDFPage;
40 }
44 namespace common {
50 class PrintDeviceSettingData FS_FINAL : public Object{
51 public:
57 typedef enum _OrientationFlag {
59 e_Portrait = 0,
61 e_Landscape = 1
62 } OrientationFlag;
63
76 explicit PrintDeviceSettingData(int device_width, int device_height, RectF device_margin, OrientationFlag orientation , int resolution, uint32 copies)
77 : device_width(device_width)
78 , device_height(device_height)
79 , device_margin(device_margin)
80 , orientation(orientation)
81 , resolution(resolution)
82 , copies(copies){}
83
90 PrintDeviceSettingData()
91 : device_width(2479)
92 , device_height(3508)
93 , orientation(e_Portrait)
94 , resolution(300)
95 , copies(1) {}
96
102 PrintDeviceSettingData(const PrintDeviceSettingData& settings)
103 : device_width(settings.device_width)
104 , device_height(settings.device_height)
105 , device_margin(settings.device_margin)
106 , orientation(settings.orientation)
107 , resolution(settings.resolution)
108 , copies(settings.copies) {}
109
117 PrintDeviceSettingData& operator = (const PrintDeviceSettingData& settings) {
118 device_width = settings.device_width;
119 device_height = settings.device_height;
120 device_margin = settings.device_margin;
121 orientation = settings.orientation;
122 resolution = settings.resolution;
123 copies = settings.copies;
124 return *this;
125 }
126
141 void Set(int device_width, int device_height, RectF device_margin, OrientationFlag orientation, int resolution, uint32 copies ) {
142 this->device_width = device_width;
143 this->device_height = device_height;
144 this->device_margin = device_margin;
145 this->orientation = orientation;
146 this->resolution = resolution;
147 this->copies = copies;
148 }
150 int device_width;
152 int device_height;
159 RectF device_margin;
164 OrientationFlag orientation;
166 int resolution;
168 uint32 copies;
169 };
170
197 class Renderer FS_FINAL : public Base {
198 public:
204 typedef enum _ColorMode {
206 e_ColorModeNormal = 0,
208 e_ColorModeMappingGray = 1,
210 e_ColorModeMapping = 2,
212 e_ColorModeAlpha = 3,
214 e_ColorModeForeground = 4
215 } ColorMode;
216
222 typedef enum _ContentFlag {
224 e_RenderPage = 0x01,
226 e_RenderAnnot = 0x02,
228 e_RenderHighlight = 0x04,
230 e_RenderExceptHighlight = 0x08,
232 e_RenderScreen = 0x10
233 } ContentFlag;
234
240 typedef enum _ColorModeForeground {
242 e_ColorModeForegroundText = 0x01,
244 e_ColorModeForegroundPath = 0x02,
246 e_ColorModeForegroundBlackText = 0x04,
248 e_ColorModeForegroundBlackPath = 0x08
249 } ColorModeForeground;
250
251 #ifdef __APPLE__
252
257 typedef enum _DeviceType {
259 e_DeviceDisplay = 1,
261 e_DevicePrinter = 2
262 }DeviceType;
263 #endif
264
277 Renderer(const Bitmap& bitmap, bool is_rgb_order);
278
291 Renderer(const PrintDeviceSettingData& print_param, const wchar_t* dest_file_path);
292
293 #if (defined(_WIN32) || defined(_WIN64)) && (!defined(SWIG) || defined(_SWIG_DOTNET_) || defined(_SWIG_PYTHON_))
294
301 explicit Renderer(HDC dc);
302
312 Renderer(HDC dc, const wchar_t* printer_driver_name);
313 #endif
314
315 #ifdef __APPLE__
316
326 Renderer(const CGContextRef& context, DeviceType device_type);
327 #endif
328
334 Renderer(const Renderer& other);
336 ~Renderer();
337
345 Renderer& operator = (const Renderer& other);
353 bool operator == (const Renderer& other) const;
361 bool operator != (const Renderer& other) const;
362
370 bool IsEmpty() const;
371
395 Progressive StartQuickRender(const pdf::PDFPage& page, const Matrix& matrix, PauseCallback* pause = NULL);
396
427 Progressive StartRender(const pdf::PDFPage& page, const Matrix& matrix, PauseCallback* pause = NULL);
428 #ifndef __EMSCRIPTEN_RENDER__
429
447 Progressive StartRenderReflowPage(const pdf::ReflowPage& reflow_page, const Matrix& matrix,
448 PauseCallback* pause = NULL);
449
450 #ifndef _FX_NO_XFA_
451
471 Progressive StartRenderXFAPage(const addon::xfa::XFAPage& xfa_page_view, const Matrix& matrix, bool is_highlight,
472 PauseCallback* pause = NULL);
473 #endif // #ifndef _FX_NO_XFA_
474 #endif
475
500 Progressive StartRenderBitmap(const Bitmap& bitmap, const Matrix& matrix,
501 const RectI* clip_rect = NULL, uint32 interpolation = 0,
502 PauseCallback* pause = NULL);
503
529 Progressive StartRenderBitmap(const Bitmap& bitmap, const Matrix& matrix,
530 const RectI* clip_rect, uint32 interpolation,
531 uint32 alpha, PauseCallback* pause);
532
533 #ifndef __EMSCRIPTEN_RENDER__
534
542 void SetRenderAnnotAppearanceType(foxit::pdf::annots::Annot::AppearanceType ap_type);
543
557 bool RenderAnnot(const pdf::annots::Annot& annot, const Matrix& matrix);
558 #endif
559
571 bool RenderFormControls(const pdf::PDFPage& page, const Matrix& matrix);
572 #ifndef __EMSCRIPTEN_RENDER__
573
586 bool RenderGraphicsObject(const pdf::graphics::GraphicsObject* graphics_object, const pdf::PDFPage& page, const Matrix& matrix);
587 #endif
588
597 void SetClipRect(const RectI* clip_rect);
598
604 void ClearClips();
605
616 void SetClipPathFill(const Path& clip_path, const Matrix& matrix, foxit::common::FillMode fill_mode);
617
628 void SetClipPathStroke(const Path& clip_path, const Matrix& matrix, const GraphState* graph_state = NULL);
629
643 void SetRenderContentFlags(uint32 render_content_flags);
644
659 void SetRenderAnnotsForThumbnail(bool is_render_annots_for_thumbnail);
660
671 void SetRenderFormField(bool is_render_formfield);
672
683 void SetRenderSignature(bool is_render_signature);
684 #ifndef __EMSCRIPTEN_RENDER__
685
695 void SetLayerContext(const pdf::LayerContext& layer_context);
696
707 void SetRenderLayer(bool is_render_one_layer);
708 #endif
709
732 void SetColorMode(ColorMode color_mode);
742 void SetMappingModeColors(ARGB background_color, ARGB foreground_color);
743
757 void SetForegroundColorMode(uint32 foreground_color_mode);
758
769 void SetForegroundColor(ARGB foreground_color);
770
781 void SetClearType(bool is_clear_type);
794 void SetPrintTextAsGraphic(bool is_to_print_text_graphic);
795
806 void SetPrintTextAsImage(bool is_to_print_text_image);
807
818 void SetForceDownSample(bool is_to_force_down_sample);
819
829 void SetOverprint(bool is_to_enable_overprint);
830
844 void SetJPEGDownSample(bool is_jepg_down_sample);
845
859 void SetJPXDownSample(bool is_jpx_down_sample);
860
873 void EnableForPrint(bool is_render_for_print);
874
885 void SetForceHalftone(bool is_to_force_halftone);
886
897 void SetRenderPathThinLine(bool is_render_path_thin_line);
898
909 void SetRenderTextAntiAliasing(bool is_render_text_antialiasing);
910
921 void SetRenderPathAntiAliasing(bool is_render_path_antialiasing);
922
932 void SetRenderPathFullCovered(bool is_render_path_full_covered);
933
945 void SetRenderImageAntiAliasing(bool is_render_image_antialiasing);
946
958 void SetRenderEnhanceThinLines(bool is_render_enhance_thin_lines);
959
968 void SetRenderSignatureState(bool is_render_signature_state);
969
970 // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
971 explicit Renderer(FS_HANDLE handle = NULL);
972
989 void SetScreenDPIScale(float scale);
990
991 };
992 } // namespace common
993 } // namespace foxit
994 #endif // FS_RENDER_H_
995
foxit::pdf::graphics::GraphicsObject
Definition: fs_pdfgraphicsobject.h:241
foxit::common::Renderer::SetRenderContentFlags
void SetRenderContentFlags(uint32 render_content_flags)
Set rendering flag to decide what content will be rendered.
foxit::common::PrintDeviceSettingData::PrintDeviceSettingData
PrintDeviceSettingData()
Constructor and set the default value.
Definition: fs_render.h:90
fs_reflowpage.h
Header file for PDF reflow page related definitions and classes.
foxit::common::Renderer::ClearClips
void ClearClips()
Clear the clipping rectangle set by function Renderer::SetClipRect.
foxit::common::Renderer::StartRenderBitmap
Progressive StartRenderBitmap(const Bitmap &bitmap, const Matrix &matrix, const RectI *clip_rect=0, uint32 interpolation=0, PauseCallback *pause=0)
Start to render a bitmap.
foxit::pdf::ReflowPage
Definition: fs_reflowpage.h:62
foxit::common::Renderer::SetRenderAnnotAppearanceType
void SetRenderAnnotAppearanceType(foxit::pdf::annots::Annot::AppearanceType ap_type)
Set the annotation's appearance type for rendering.
foxit::common::PrintDeviceSettingData::PrintDeviceSettingData
PrintDeviceSettingData(int device_width, int device_height, RectF device_margin, OrientationFlag orientation, int resolution, uint32 copies)
Constructor, with parameters.
Definition: fs_render.h:76
foxit::common::Renderer::operator=
Renderer & operator=(const Renderer &other)
Assign operator.
foxit::common::PrintDeviceSettingData::Set
void Set(int device_width, int device_height, RectF device_margin, OrientationFlag orientation, int resolution, uint32 copies)
Set value.
Definition: fs_render.h:141
foxit::Object
CFX_Object Object
Object type.
Definition: fs_basictypes.h:220
foxit::common::PauseCallback
IFX_Pause PauseCallback
Definition: fs_common.h:1292
foxit::common::Renderer::ColorModeForeground
ColorModeForeground
Enumeration for rendering foreground color mode.
Definition: fs_render.h:240
foxit::common::Renderer::SetJPXDownSample
void SetJPXDownSample(bool is_jpx_down_sample)
Set the flag to decide whether to use down-sampling for jpx image.
foxit::common::Renderer::SetRenderImageAntiAliasing
void SetRenderImageAntiAliasing(bool is_render_image_antialiasing)
Set the flag to decide whether to draw image anti-aliasing.
foxit::common::Renderer::StartQuickRender
Progressive StartQuickRender(const pdf::PDFPage &page, const Matrix &matrix, PauseCallback *pause=0)
Start to quickly render a PDF page, mainly for thumbnail purpose.
foxit::common::Renderer::e_ColorModeForegroundText
If set, the color of text need to be replaced.
Definition: fs_render.h:242
foxit::addon::xfa::XFAPage
Definition: fs_xfa.h:1356
foxit::common::Renderer::EnableForPrint
void EnableForPrint(bool is_render_for_print)
Set the flag to decide whether to do rendering in print mode.
foxit::common::Renderer::SetOverprint
void SetOverprint(bool is_to_enable_overprint)
Set the flag to decide whether to enable overprint.
foxit::common::Renderer::SetClipRect
void SetClipRect(const RectI *clip_rect)
Set the clipping rectangle which will be used in subsequent rendering progress.
foxit::common::Renderer::e_RenderPage
If set, page content will be rendered.
Definition: fs_render.h:224
foxit::common::Renderer::~Renderer
~Renderer()
Destructor.
foxit::common::Renderer::SetRenderPathAntiAliasing
void SetRenderPathAntiAliasing(bool is_render_path_antialiasing)
Set the flag to decide whether to draw path anti-aliasing.
foxit::common::Renderer::ColorMode
ColorMode
Enumeration for rendering color mode.
Definition: fs_render.h:204
foxit::common::Renderer::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::common::Renderer::StartRenderXFAPage
Progressive StartRenderXFAPage(const addon::xfa::XFAPage &xfa_page_view, const Matrix &matrix, bool is_highlight, PauseCallback *pause=0)
Start to render an XFA page.
foxit::common::PrintDeviceSettingData::copies
uint32 copies
The number of copies to be printed. This parameter only has an effect on PostScrip files.
Definition: fs_render.h:168
foxit::common::Renderer::SetRenderTextAntiAliasing
void SetRenderTextAntiAliasing(bool is_render_text_antialiasing)
Set the flag to decide whether to draw text anti-aliasing.
foxit::common::Renderer::SetForceHalftone
void SetForceHalftone(bool is_to_force_halftone)
Set the flag to decide whether to use halftone for image stretching.
foxit::common::PrintDeviceSettingData::PrintDeviceSettingData
PrintDeviceSettingData(const PrintDeviceSettingData &settings)
Constructor, with another print device setting data object.
Definition: fs_render.h:102
foxit::common::Renderer::SetJPEGDownSample
void SetJPEGDownSample(bool is_jepg_down_sample)
Set the flag to decide whether to use down-sampling for jpeg image.
fs_pdflayer.h
Header file for PDF layer related definitions and classes.
fs_image.h
Header file for image and bitmap related definitions and classes.
foxit::common::Renderer::e_ColorModeForeground
Custom color mode. map colors to foreground.
Definition: fs_render.h:214
foxit::common::Renderer::e_ColorModeMappingGray
Map gray/white/black color value to background/foreground; for other colors, no change.
Definition: fs_render.h:208
foxit::common::Renderer::SetColorMode
void SetColorMode(ColorMode color_mode)
Set color mode.
foxit::common::Renderer
Definition: fs_render.h:197
foxit::common::Renderer::SetRenderPathFullCovered
void SetRenderPathFullCovered(bool is_render_path_full_covered)
A special flag that can be applied to fill mode.
foxit::common::Renderer::SetClipPathFill
void SetClipPathFill(const Path &clip_path, const Matrix &matrix, foxit::common::FillMode fill_mode)
Set clipping path using filled region.
foxit::ARGB
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:209
foxit::common::Renderer::StartRenderReflowPage
Progressive StartRenderReflowPage(const pdf::ReflowPage &reflow_page, const Matrix &matrix, PauseCallback *pause=0)
Start to render a reflow page.
foxit::common::Renderer::SetRenderAnnotsForThumbnail
void SetRenderAnnotsForThumbnail(bool is_render_annots_for_thumbnail)
Set rendering flag to decide whether to render annotations in thumbnail mode or not.
foxit::common::PrintDeviceSettingData::device_width
int device_width
The width of the device in pixels.
Definition: fs_render.h:150
foxit::common::Renderer::SetClearType
void SetClearType(bool is_clear_type)
Set the flag to decide whether to use ClearType-like anti-aliasing to render text objects.
fs_annot.h
Header file for annotation related definitions and classes.
foxit::common::FillMode
FillMode
Enumeration for filling mode type, mainly for path graphics object.
Definition: fs_common.h:108
foxit::common::PrintDeviceSettingData::OrientationFlag
OrientationFlag
Enumeration for specifying the orientation of the printer.
Definition: fs_render.h:57
foxit::common::Renderer::Renderer
Renderer(const Bitmap &bitmap, bool is_rgb_order)
Constructor, with bitmap.
foxit::common::Renderer::SetRenderPathThinLine
void SetRenderPathThinLine(bool is_render_path_thin_line)
Set the flag to decide whether to draw path as thin line.
foxit::common::PrintDeviceSettingData::resolution
int resolution
The resolution of the device in pixels per inch.
Definition: fs_render.h:166
foxit::common::Renderer::SetRenderFormField
void SetRenderFormField(bool is_render_formfield)
Set the flag to decide whether to render form fields (except signature fields).
foxit::common::Renderer::e_ColorModeMapping
Map a color value to the color range defined by a background color and a foreground color.
Definition: fs_render.h:210
foxit::common::Renderer::e_RenderAnnot
If set, annotations will be rendered.
Definition: fs_render.h:226
foxit::uint32
FX_UINT32 uint32
32-bit unsigned integer.
Definition: fs_basictypes.h:195
foxit::common::Renderer::e_ColorModeForegroundBlackText
If set, only the black color of text need to be replaced.
Definition: fs_render.h:246
foxit::pdf::PDFPage
Definition: fs_pdfpage.h:412
foxit::FS_HANDLE
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
foxit::common::PrintDeviceSettingData::operator=
PrintDeviceSettingData & operator=(const PrintDeviceSettingData &settings)
Assign operator.
Definition: fs_render.h:117
fs_common.h
Header file for common definitions and classes.
foxit::common::Renderer::StartRender
Progressive StartRender(const pdf::PDFPage &page, const Matrix &matrix, PauseCallback *pause=0)
Start to render a PDF page.
foxit::common::Renderer::e_ColorModeNormal
Normal color mode.
Definition: fs_render.h:206
foxit::common::Renderer::operator !=
bool operator !=(const Renderer &other) const
Not equal operator.
foxit::common::Renderer::SetForegroundColor
void SetForegroundColor(ARGB foreground_color)
Set foreground color for text, path or both when color mode is Renderer::e_ColorModeForeground.
foxit::common::PrintDeviceSettingData::e_Landscape
Landscape orientation for printing.
Definition: fs_render.h:61
FX_RECT
Definition: fx_coordinates.h:596
foxit::common::PrintDeviceSettingData::orientation
OrientationFlag orientation
Orientation flag. Please refer to values starting from OrientationFlag::e_Portrait and this should be...
Definition: fs_render.h:164
foxit::common::Renderer::e_ColorModeForegroundPath
If set, the color of path need to be replaced.
Definition: fs_render.h:244
foxit::common::Renderer::e_ColorModeForegroundBlackPath
If set, only the black color of path need to be replaced.
Definition: fs_render.h:248
foxit::common::PrintDeviceSettingData
Definition: fs_render.h:50
foxit::common::Renderer::e_ColorModeAlpha
Output alpha only, ignore color.
Definition: fs_render.h:212
foxit::Base
Definition: fs_basictypes.h:451
foxit::common::Renderer::e_RenderHighlight
If set, only highlight annotations will be rendered.
Definition: fs_render.h:228
foxit::pdf::LayerContext
Definition: fs_pdflayer.h:338
foxit::common::Renderer::RenderGraphicsObject
bool RenderGraphicsObject(const pdf::graphics::GraphicsObject *graphics_object, const pdf::PDFPage &page, const Matrix &matrix)
Render a graphics object.
foxit::common::Renderer::SetLayerContext
void SetLayerContext(const pdf::LayerContext &layer_context)
Set layer context to render context handle.
foxit::common::Renderer::SetForceDownSample
void SetForceDownSample(bool is_to_force_down_sample)
Set the flag to decide whether to use down-sampling for image stretching.
fs_xfa.h
Header file for XFA related definitions and functions.
foxit::common::Renderer::RenderAnnot
bool RenderAnnot(const pdf::annots::Annot &annot, const Matrix &matrix)
Render a specified annotation.
foxit::pdf::annots::Annot
Definition: fs_annot.h:1006
foxit::common::Renderer::SetRenderSignature
void SetRenderSignature(bool is_render_signature)
Set the flag to decide whether to render signatures or not.
foxit
Foxit namespace.
Definition: fs_pdf3d.h:26
foxit::common::PrintDeviceSettingData::device_height
int device_height
The height of the device in pixels.
Definition: fs_render.h:152
foxit::pdf::annots::Annot::AppearanceType
AppearanceType
Enumeration for the type of annotation's appearance.
Definition: fs_annot.h:1290
foxit::common::Renderer::SetPrintTextAsImage
void SetPrintTextAsImage(bool is_to_print_text_image)
Set the flag to decide whether to print text as image.
foxit::common::Renderer::ContentFlag
ContentFlag
Enumeration for rendering content flags.
Definition: fs_render.h:222
foxit::common::Renderer::SetMappingModeColors
void SetMappingModeColors(ARGB background_color, ARGB foreground_color)
Set background color and foreground color when color mode is Renderer::e_ColorModeMappingGray or Rend...
foxit::common::PrintDeviceSettingData::e_Portrait
Portrait orientation for printing.
Definition: fs_render.h:59
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:792
foxit::common::Renderer::SetForegroundColorMode
void SetForegroundColorMode(uint32 foreground_color_mode)
Set rendering foreground color mode when color mode is Renderer::e_ColorModeForeground.
foxit::common::Renderer::operator==
bool operator==(const Renderer &other) const
Equal operator.
foxit::common::Renderer::SetRenderSignatureState
void SetRenderSignatureState(bool is_render_signature_state)
Set the flag to decide whether to draw the signature state on the signature.
foxit::common::PrintDeviceSettingData::device_margin
RectF device_margin
The page margins of the device.
Definition: fs_render.h:159
CFX_Matrix
Definition: fx_coordinates.h:1076
foxit::common::Renderer::SetPrintTextAsGraphic
void SetPrintTextAsGraphic(bool is_to_print_text_graphic)
Set the flag to decide whether to print text as path or bitmap.
foxit::common::Renderer::e_RenderScreen
If set, only screen annotations will be rendered.
Definition: fs_render.h:232
foxit::common::Renderer::e_RenderExceptHighlight
If set, all annotations expect highlight will be rendered.
Definition: fs_render.h:230
foxit::common::Renderer::RenderFormControls
bool RenderFormControls(const pdf::PDFPage &page, const Matrix &matrix)
Render form controls.
foxit::common::Renderer::SetRenderEnhanceThinLines
void SetRenderEnhanceThinLines(bool is_render_enhance_thin_lines)
Set the flag to decide whether to enhance thin lines.
foxit::common::Renderer::SetClipPathStroke
void SetClipPathStroke(const Path &clip_path, const Matrix &matrix, const GraphState *graph_state=0)
Set clipping path using stroked region.
foxit::common::Renderer::SetRenderLayer
void SetRenderLayer(bool is_render_one_layer)
Set the flag to decide whether to render one layer or all available layers.
CFX_FloatRect
Definition: fx_coordinates.h:771
foxit::common::Renderer::SetScreenDPIScale
void SetScreenDPIScale(float scale)
Set the screen DPI scaling factor for rendering.