com.foxit.sdk.common.Renderer Class Reference
Inheritance diagram for com.foxit.sdk.common.Renderer:
com.foxit.sdk.common.Base

Public Member Functions

 Renderer (Bitmap bitmap, boolean is_rgb_order) throws com.foxit.sdk.PDFException
 Constructor, with bitmap. More...
 
 Renderer (Renderer other)
 Constructor, with another Renderer object. More...
 
boolean isEmpty ()
 Check whether current object is empty or not. More...
 
boolean renderAnnot (Annot annot, Matrix2D matrix) throws com.foxit.sdk.PDFException
 Render a specified annotation. More...
 
void setClearType (boolean is_clear_type) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to use ClearType-like anti-aliasing to render text objects. More...
 
void setClipPathFill (Path clip_path, Matrix2D matrix, int fill_mode) throws com.foxit.sdk.PDFException
 Set clipping path using filled region. More...
 
void setClipPathStroke (Path clip_path, Matrix2D matrix, GraphState graph_state) throws com.foxit.sdk.PDFException
 Set clipping path using stroked region. More...
 
void setClipRect (RectI clip_rect) throws com.foxit.sdk.PDFException
 Set the clipping rectangle which will be used in following rendering progress. More...
 
void setColorMode (int color_mode) throws com.foxit.sdk.PDFException
 Set color mode. More...
 
void setForceDownSample (boolean is_to_force_down_sample) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to use down-sampling for image stretching. More...
 
void setForceHalftone (boolean is_to_force_halftone) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to use halftone for image stretching. More...
 
void setLayerContext (LayerContext layer_context) throws com.foxit.sdk.PDFException
 Set layer context to render context handle. More...
 
void setMappingModeColors (long background_color, long foreground_color) throws com.foxit.sdk.PDFException
 Set background color and foreground color when color mode is e_ColorModeMapping. More...
 
void setPrintTextAsGraphic (boolean is_to_print_text_graphic) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to print text as path or bitmap. More...
 
void setPrintTextAsImage (boolean is_to_print_text_image) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to print text as image. More...
 
void setRenderContentFlags (int render_content_flags) throws com.foxit.sdk.PDFException
 Set rendering flag to decide what content will be rendered. More...
 
void setRenderFormField (boolean is_render_formfield) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to render form fields (except signature fields). More...
 
void setRenderImageAntiAliasing (boolean is_render_image_antialiasing) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to draw image anti-aliasing. More...
 
void setRenderPathAntiAliasing (boolean is_render_path_antialiasing) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to draw path anti-aliasing. More...
 
void setRenderPathThinLine (boolean is_render_path_thin_line) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to draw path as thin line. More...
 
void setRenderSignature (boolean is_render_signature) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to render signatures or not. More...
 
void setRenderTextAntiAliasing (boolean is_render_text_antialiasing) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to draw text anti-aliasing. More...
 
void setTransformAnnotIcon (boolean is_to_transform_annot_icon) throws com.foxit.sdk.PDFException
 Set the flag to decide whether to transform annotation icon or not when display. More...
 
Progressive startQuickRender (PDFPage page, Matrix2D matrix, PauseCallback pause) throws com.foxit.sdk.PDFException
 Start to quickly render a PDF page, mainly for thumbnail purpose. More...
 
Progressive startRender (PDFPage page, Matrix2D matrix, PauseCallback pause) throws com.foxit.sdk.PDFException
 Start to render a PDF page. More...
 
Progressive startRenderBitmap (Bitmap bitmap, Matrix2D matrix, RectI clip_rect, int interpolation, PauseCallback pause) throws com.foxit.sdk.PDFException
 Start to render a bitmap. More...
 
Progressive startRenderReflowPage (ReflowPage reflow_page, Matrix2D matrix, PauseCallback pause) throws com.foxit.sdk.PDFException
 Start to render a reflow page. More...
 
Progressive startRenderXFAPage (XFAPage xfa_page_view, Matrix2D matrix, boolean is_highlight, PauseCallback pause) throws com.foxit.sdk.PDFException
 Start to render an XFA page. More...
 

Static Public Attributes

static final int e_ColorModeMapping = 2
 Map a color value to the color range defined by a background color and a foreground color.
 
static final int e_ColorModeNormal = 0
 Normal color mode.
 
static final int e_RenderAnnot = 0x02
 If set, annotations will be rendered.
 
static final int e_RenderPage = 0x01
 If set, page content will be rendered.
 

Detailed Description

PDF renderer is a graphics engine and is used to render page to a bitmap or a platform device context. This class can be constructed with a bitmap, or a device object. It offers functions to set rendering options/flags, and do rendering. In this class, there are several ways to do rendering:


To render page and annotations, first use function Renderer::setRenderContentFlags to decide whether to render page and annotation both or not, and then use functions Renderer::startRender to do the rendering. Function Renderer::startQuickRender can also be used to render page but only for thumbnail purpose.
To render a single annotation, use function Renderer::renderAnnot.
To render a bitmap, use function Renderer::startRenderBitmap.
To render a reflow page, use function Renderer::startRenderReflowPage.
Widget annotation is always associated with form field and form control in Foxit PDF SDK. For how to render widget annotations, here is a recommended flow:


  1. After loading a PDF page, first render the page and all annotations in this page (including widget annotations).
  2. Then, if user uses pdf::interform::Filler object to fill the form, user should use function pdf::interform::Filler::startQuickRender to render the focused form control instead of using function Renderer::renderAnnot.

See also
pdf::interform::Filler

Constructor & Destructor Documentation

◆ Renderer() [1/2]

com.foxit.sdk.common.Renderer.Renderer ( Bitmap  bitmap,
boolean  is_rgb_order 
) throws com.foxit.sdk.PDFException

Constructor, with bitmap.

The input bitmap is treated as an independent device and all the content rendered by the renderer would appear in the bitmap.

Parameters
bitmapA bitmap used for rendering. User should ensure the bitmap to keep valid until the end of life cycle of current renderer object.
is_rgb_ordertrue means Foxit PDF SDK needs to use RGB byte-order (Red is in the lowest order) when rendering. false means Foxit PDF SDK needs to use BGR byte-order (Blue is in the lowest order) when rendering.

◆ Renderer() [2/2]

com.foxit.sdk.common.Renderer.Renderer ( Renderer  other)

Constructor, with another Renderer object.

Parameters
otherAnother Renderer object.

Member Function Documentation

◆ isEmpty()

boolean com.foxit.sdk.common.Renderer.isEmpty ( )

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ renderAnnot()

boolean com.foxit.sdk.common.Renderer.renderAnnot ( Annot  annot,
Matrix2D  matrix 
) throws com.foxit.sdk.PDFException

Render a specified annotation.

When this function is called, rendering flag (set by function Renderer::setRenderContentFlags or by default) will be ignored.

Parameters
annotAn Annot object to be rendered. If input annot is a pop-up annotation, this function will not render it and will return false.
matrixThe transformation matrix used for rendering, which is usually returned by function pdf::PDFPage::getDisplayMatrix.
Returns
true means success, while false means failure.

◆ setClearType()

void com.foxit.sdk.common.Renderer.setClearType ( boolean  is_clear_type) throws com.foxit.sdk.PDFException

Set the flag to decide whether to use ClearType-like anti-aliasing to render text objects.

If this function is not called, default value true will be used.

Parameters
is_clear_typetrue means to use ClearType-like anti-aliasing to render text objects. false means not to use ClearType-like anti-aliasing to render text objects.
Returns
None.

◆ setClipPathFill()

void com.foxit.sdk.common.Renderer.setClipPathFill ( Path  clip_path,
Matrix2D  matrix,
int  fill_mode 
) throws com.foxit.sdk.PDFException

Set clipping path using filled region.

Parameters
clip_pathA clipping path.
matrixThe transformation matrix used for clipping.
fill_modeFill mode. It should be value e_FillModeAlternate or e_FillModeWinding.
Returns
None.

◆ setClipPathStroke()

void com.foxit.sdk.common.Renderer.setClipPathStroke ( Path  clip_path,
Matrix2D  matrix,
GraphState  graph_state 
) throws com.foxit.sdk.PDFException

Set clipping path using stroked region.

Parameters
clip_pathA clipping path.
matrixThe transformation matrix used for clipping.
graph_stateNew graph state, for pen attributes. It can be null.
Returns
None.

◆ setClipRect()

void com.foxit.sdk.common.Renderer.setClipRect ( RectI  clip_rect) throws com.foxit.sdk.PDFException

Set the clipping rectangle which will be used in following rendering progress.

Parameters
clip_rectA clipping rectangle. If it is null, that means not to use clipping rectangle in following rendering progress.
Returns
None.

◆ setColorMode()

void com.foxit.sdk.common.Renderer.setColorMode ( int  color_mode) throws com.foxit.sdk.PDFException

Set color mode.

If this function is not called, default value e_ColorModeNormal will be used.

Parameters
color_modeColor mode value. It should be one of following values:

e_ColorModeNormal means normal color mode.
e_ColorModeMapping means to map a color value to the color range defined by a background color and a foreground color. If this mode is used, please call function Renderer::setMappingModeColors to set "background color" and "foreground color".

Returns
None.

◆ setForceDownSample()

void com.foxit.sdk.common.Renderer.setForceDownSample ( boolean  is_to_force_down_sample) throws com.foxit.sdk.PDFException

Set the flag to decide whether to use down-sampling for image stretching.

If this function is not called, default value false will be used.

Parameters
is_to_force_down_sampletrue means to use down-sampling for image stretching. false means not to use down-sampling for image stretching.
Returns
None.

◆ setForceHalftone()

void com.foxit.sdk.common.Renderer.setForceHalftone ( boolean  is_to_force_halftone) throws com.foxit.sdk.PDFException

Set the flag to decide whether to use halftone for image stretching.

If this function is not called, default value true will be used.

Parameters
is_to_force_halftonetrue means to use halftone for image stretching. false means not to use halftone for image stretching.
Returns
None.

◆ setLayerContext()

void com.foxit.sdk.common.Renderer.setLayerContext ( LayerContext  layer_context) throws com.foxit.sdk.PDFException

Set layer context to render context handle.

In order to render one layer when PDF page's contents is rendered on a rendering context, user should call this function to set the layer context to render context.

Parameters
layer_contextA LayerContext object.
Returns
None.

◆ setMappingModeColors()

void com.foxit.sdk.common.Renderer.setMappingModeColors ( long  background_color,
long  foreground_color 
) throws com.foxit.sdk.PDFException

Set background color and foreground color when color mode is e_ColorModeMapping.

Parameters
background_colorThe background color. Format: 0xAARRGGBB.
foreground_colorThe foreground color. Format: 0xAARRGGBB.
Returns
None.

◆ setPrintTextAsGraphic()

void com.foxit.sdk.common.Renderer.setPrintTextAsGraphic ( boolean  is_to_print_text_graphic) throws com.foxit.sdk.PDFException

Set the flag to decide whether to print text as path or bitmap.

When this flag is true, Foxit PDF SDK will render text in different way: if font size is greater than 50, print text as path; otherwise, print text as bitmap.
If this function is not called, default value false will be used.

Parameters
is_to_print_text_graphictrue means to print text as path or bitmap. false means not to print text as path or bitmap.
Returns
None.

◆ setPrintTextAsImage()

void com.foxit.sdk.common.Renderer.setPrintTextAsImage ( boolean  is_to_print_text_image) throws com.foxit.sdk.PDFException

Set the flag to decide whether to print text as image.

If this function is not called, default value false will be used.

Parameters
is_to_print_text_imagetrue means to print text as image. false means not to print text as image.
Returns
None.

◆ setRenderContentFlags()

void com.foxit.sdk.common.Renderer.setRenderContentFlags ( int  render_content_flags) throws com.foxit.sdk.PDFException

Set rendering flag to decide what content will be rendered.

If this function is not called, default value (e_RenderPage | e_RenderAnnot) will be used.

Parameters
render_content_flagsRendering content flags. Please refer to values starting from e_RenderPage and this should be one or a combination of these values.
Returns
None.

◆ setRenderFormField()

void com.foxit.sdk.common.Renderer.setRenderFormField ( boolean  is_render_formfield) throws com.foxit.sdk.PDFException

Set the flag to decide whether to render form fields (except signature fields).

If this function is not called, default value true will be used.

Parameters
is_render_formfieldtrue means to render form fields (except signature fields). false means not to render form fields (except signature fields).
Returns
None.

◆ setRenderImageAntiAliasing()

void com.foxit.sdk.common.Renderer.setRenderImageAntiAliasing ( boolean  is_render_image_antialiasing) throws com.foxit.sdk.PDFException

Set the flag to decide whether to draw image anti-aliasing.

If this function is not called, default value true will be used.

Parameters
is_render_image_antialiasingtrue means to draw image anti-aliasing, and the effect would be similar to values defined in enum class InterpolationFlag. false means to draw image aliasing.
Returns
None.

◆ setRenderPathAntiAliasing()

void com.foxit.sdk.common.Renderer.setRenderPathAntiAliasing ( boolean  is_render_path_antialiasing) throws com.foxit.sdk.PDFException

Set the flag to decide whether to draw path anti-aliasing.

If this function is not called, default value true will be used.

Parameters
is_render_path_antialiasingtrue means to draw path anti-aliasing. false means to draw path aliasing.
Returns
None.

◆ setRenderPathThinLine()

void com.foxit.sdk.common.Renderer.setRenderPathThinLine ( boolean  is_render_path_thin_line) throws com.foxit.sdk.PDFException

Set the flag to decide whether to draw path as thin line.

If this function is not called, default value false will be used.

Parameters
is_render_path_thin_linetrue means to draw path as thin line. false means not to draw path as thin line.
Returns
None.

◆ setRenderSignature()

void com.foxit.sdk.common.Renderer.setRenderSignature ( boolean  is_render_signature) throws com.foxit.sdk.PDFException

Set the flag to decide whether to render signatures or not.

If this function is not called, default value true will be used.

Parameters
is_render_signaturetrue means to render signatures. false means not to render signatures.
Returns
None.

◆ setRenderTextAntiAliasing()

void com.foxit.sdk.common.Renderer.setRenderTextAntiAliasing ( boolean  is_render_text_antialiasing) throws com.foxit.sdk.PDFException

Set the flag to decide whether to draw text anti-aliasing.

If this function is not called, default value true will be used.

Parameters
is_render_text_antialiasingtrue means to draw text anti-aliasing. false means to draw text aliasing.
Returns
None.

◆ setTransformAnnotIcon()

void com.foxit.sdk.common.Renderer.setTransformAnnotIcon ( boolean  is_to_transform_annot_icon) throws com.foxit.sdk.PDFException

Set the flag to decide whether to transform annotation icon or not when display.

The flag set by this function is only useful for note and file attachment annotations. If this function is not called, default value true will be used.

Parameters
is_to_transform_annot_icontrue means to transform annotation icon when display. false means not to transform annotation icon when display.
Returns
None.

◆ startQuickRender()

Progressive com.foxit.sdk.common.Renderer.startQuickRender ( PDFPage  page,
Matrix2D  matrix,
PauseCallback  pause 
) throws com.foxit.sdk.PDFException

Start to quickly render a PDF page, mainly for thumbnail purpose.

This function is mainly used for render a page for thumbnail purpose. The rendered content will not be completed: all the annotations will be ignored, event if flag e_RenderAnnot is set by function Renderer::setRenderContentFlags; text content will become blurred and will be replace by pixel point.
It may still take a long time to do this quick rendering when page has complex or large contents, so Foxit PDF SDK uses a progressive process to do this.

Parameters
pageA valid PDF page. It should have been parsed.
matrixThe transformation matrix used for rendering, which is usually returned by function pdf::PDFPage::getDisplayMatrix.
pausePause callback object which decides if the rendering process needs to be paused. This can be null which means not to pause during the rendering process. If this is not null, it should be a valid pause object implemented by user.
Returns
A Progressive object. Please check the rate of current progress by function common::Progressive::getRateOfProgress. If the rate is not 100 yet, call function common::Progressive::resume to coninue the progress until the progress is finished.

◆ startRender()

Progressive com.foxit.sdk.common.Renderer.startRender ( PDFPage  page,
Matrix2D  matrix,
PauseCallback  pause 
) throws com.foxit.sdk.PDFException

Start to render a PDF page.

It may take a long time to render a PDF page with complex or large contents, so Foxit PDF SDK uses a progressive process to do this.
Widget annotation is always associated with form field and form control in Foxit PDF SDK. For how to render widget annotations, here is a recommended flow:


After loading a PDF page, first render the page and all annotations in this page (including widget annotations).
Then, if user uses pdf::interform::Filler object to fill the form, user should use function pdf::interform::Filler::startQuickRender to render the focused form control instead of using function Renderer::renderAnnot.

Parameters
pageA valid PDF page. If only to render annotations (that means only e_RenderAnnot is set by function Renderer::setRenderContentFlags), there is no need to parse the input page; otherwise the input page should have been parsed.
matrixThe transformation matrix used for rendering, which is usually returned by function pdf::PDFPage::getDisplayMatrix.
pausePause callback object which decides if the rendering process needs to be paused. This can be null which means not to pause during the rendering process. If this is not null, it should be a valid pause object implemented by user.
Returns
A Progressive object. Please check the rate of current progress by function common::Progressive::getRateOfProgress. If the rate is not 100 yet, call function common::Progressive::resume to coninue the progress until the progress is finished.

◆ startRenderBitmap()

Progressive com.foxit.sdk.common.Renderer.startRenderBitmap ( Bitmap  bitmap,
Matrix2D  matrix,
RectI  clip_rect,
int  interpolation,
PauseCallback  pause 
) throws com.foxit.sdk.PDFException

Start to render a bitmap.

It may take a long time to render a bitmap with complex or large contents, so Foxit PDF SDK uses a progressive process to do this.

Parameters
bitmapA valid bitmap. User should ensure the bitmap to keep valid until current rendering process is finished.
matrixThe transformation matrix used for rendering. This matrix is used as image matrix:
assume that h is image height, w is image width, and then matrix [w 0 0 h 0 0] will produce an identical image.
clip_rectClip rectangle for the rendering device. This can be null.
interpolationBitmap interpolation flags. Please refer to values starting from e_Downsample and this can be one or a combination of these values. If not specify any flag, please use 0.
pausePause callback object which decides if the rendering process needs to be paused. This can be null which means not to pause during the rendering process. If this is not null, it should be a valid pause object implemented by user.
Returns
A Progressive object. Please check the rate of current progress by function common::Progressive::getRateOfProgress. If the rate is not 100 yet, call function common::Progressive::resume to coninue the progress until the progress is finished.

◆ startRenderReflowPage()

Progressive com.foxit.sdk.common.Renderer.startRenderReflowPage ( ReflowPage  reflow_page,
Matrix2D  matrix,
PauseCallback  pause 
) throws com.foxit.sdk.PDFException

Start to render a reflow page.

It may take a long time to render a reflow page with complex or large contents, so Foxit PDF SDK uses a progressive process to do this.

Parameters
reflow_pageA valid reflow page. It should have been parsed.
matrixThe transformation matrix used for rendering, which is usually returned by function pdf::ReflowPage::getDisplayMatrix.
pausePause callback object which decides if the rendering process needs to be paused. This can be null which means not to pause during the rendering process. If this is not null, it should be a valid pause object implemented by user.
Returns
A Progressive object. Please check the rate of current progress by function common::Progressive::getRateOfProgress. If the rate is not 100 yet, call function common::Progressive::resume to coninue the progress until the progress is finished.

◆ startRenderXFAPage()

Progressive com.foxit.sdk.common.Renderer.startRenderXFAPage ( XFAPage  xfa_page_view,
Matrix2D  matrix,
boolean  is_highlight,
PauseCallback  pause 
) throws com.foxit.sdk.PDFException

Start to render an XFA page.

It will take a long time to render an XFA page with complex or large contents, so Foxit PDF SDK uses a progressive process to do this.

Parameters
xfa_page_viewA valid XFA page.
matrixThe transformation matrix used for rendering, which is usually returned by function addon::xfa::XFAPage::getDisplayMatrix.
is_highlighttrue means to highlight XFA widgets, and false means not to highlight XFA widgets.
pausePause callback object which decides if the rendering process needs to be paused. This can be null which means not to pause during the rendering process. If this is not null, it should be a valid pause object implemented by user.
Returns
A Progressive object. Please check the rate of current progress by function common::Progressive::getRateOfProgress. If the rate is not 100 yet, call function common::Progressive::resume to coninue the progress until the progress is finished.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.