Class: PDFRasterizer

Core.PDFNet. PDFRasterizer


new PDFRasterizer()

PDFRasterizer is a low-level PDF rasterizer. The main purpose of this class is to convert PDF pages to raster images (or bitmaps). Note: PDFRasterizer is a relatively low-level class. If you need to convert PDF page to an image format or a Bitmap, consider using PDFNet.PDFDraw. Similarly, if you are building an interactive PDF viewing application you may want to use PDFNet.PDFView instead.

Extends

Members


<static> ColorPostProcessMode

Properties:
Name Type Description
e_postprocess_none number
e_postprocess_invert number
e_postprocess_gradient_map number
e_postprocess_night_mode number

<static> OverprintPreviewMode

Properties:
Name Type Description
e_op_off number
e_op_on number
e_op_pdfx_on number

<static> Type

Properties:
Name Type Description
e_BuiltIn number
e_GDIPlus number

Methods


<static> create( [type])

PdFRasterizer constructor and destructor
Parameters:
Name Type Argument Description
type number <optional>
PDFNet.PDFRasterizer.Type = {
	e_BuiltIn : 0
	e_GDIPlus : 1
}
Returns:
A promise that resolves to an object of type: "PDFNet.PDFRasterizer"
Type
Promise.<Core.PDFNet.PDFRasterizer>

destroy()

Destructor
Inherited From:
Returns:
Type
Promise.<void>

enableDisplayListCaching(enabled)

Parameters:
Name Type Description
enabled boolean
Returns:
Type
Promise.<void>

getColorPostProcessMode()

Returns:
A promise that resolves to the current color post processing mode.
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.PDFRasterizer.ColorPostProcessMode = {
	e_postprocess_none : 0
	e_postprocess_invert : 1
	e_postprocess_gradient_map : 2
	e_postprocess_night_mode : 3
}
</pre>

getRasterizerType()

Returns:
A promise that resolves to the type of current rasterizer. Note: This method is deprecated, since the GDI+ rasterizer itself is deprecated and will be removed in a future version of PDFNet. It is strongly recommended to use the built-in rasterizer and to use the XPS print path where vector conversion is needed.
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.PDFRasterizer.Type = {
	e_BuiltIn : 0
	e_GDIPlus : 1
}
</pre>

rasterize(page, width, height, stride, num_comps, demult, device_mtx [, clip] [, scrl_clp_regions])

Draws the page into a given memory buffer.
Parameters:
Name Type Argument Description
page Core.PDFNet.Page The page to rasterize.
width number The width of the target image in pixels.
height number The height of the target image in pixels (the number of rows).
stride number Stride determines the physical width (in bytes) of one row in memory. If this value is negative the direction of the Y axis is inverted. The absolute value of stride is of importance, because it allows rendering in buffers where rows are padded in memory (e.g. in Windows bitmaps are padded on 4 byte boundaries). Besides allowing rendering on the whole buffer stride parameter can be used for rendering in a rectangular subset of a buffer.
num_comps number The number (4 or 5) representing the number of color components in the device color space. For BGR+Alpha set this parameter to 4, and for CMYK+Alpha use 5. If other values are set, exceptions will be thrown.
demult boolean Specifies if the alpha is de-multiplied from the resulting color components.
device_mtx Core.PDFNet.Matrix2D Device transformation matrix that maps PDF page from PDF user space into device coordinate space (e.g. pixel space). PDF user space is represented in page units, where one unit corresponds to 1/72 of an inch.
clip Core.PDFNet.Rect <optional>
Optional parameter defining the clip region for the page. If the parameter is null or is not specified, PDFRasterizer uses page's crop box as a default clip region.
scrl_clp_regions Core.PDFNet.Rect <optional>
Optional parameter reserved for a future use.
Returns:
a memory buffer. The buffer must contain at least (stride * height) bytes.
Type
Promise.<Uint8Array>

rasterizeAnnot(annot, page, device_mtx, demult, cancel)

Parameters:
Name Type Description
annot Core.PDFNet.Annot
page Core.PDFNet.Page
device_mtx Core.PDFNet.Matrix2D
demult boolean
cancel boolean
Returns:
A promise that resolves to an object of type: "PDFNet.OwnedBitmap"
Type
Promise.<Core.PDFNet.OwnedBitmap>

rasterizeSeparations(page, width, height, mtx, clip, cancel)

Draws the page into a given memory buffer. Note: This method is available on all platforms and in all rasterizer implementations.
Parameters:
Name Type Description
page Core.PDFNet.Page The page to rasterize.
width number The width of the target image in pixels.
height number The height of the target image in pixels (the number of rows).
mtx Core.PDFNet.Matrix2D Device transformation matrix that maps PDF page from PDF user space into device coordinate space (e.g. pixel space). PDF user space is represented in page units, where one unit corresponds to 1/72 of an inch.
clip Core.PDFNet.Rect Optional parameter defining the clip region for the page. If the parameter is null or is not specified, PDFRasterizer uses page's crop box as a default clip region.
cancel boolean An optional variable that can be used to stop the rendering thread.
Returns:
A promise that resolves to an object of type: "Array"
Type
Promise.<Array.<Core.PDFNet.Separation>>

setAnnotationState(annot, new_view_state)

Parameters:
Name Type Description
annot Core.PDFNet.Annot
new_view_state number
PDFNet.Annot.State = {
	e_normal : 0
	e_rollover : 1
	e_down : 2
}
Returns:
Type
Promise.<void>

setAntiAliasing(enable_aa)

Enable or disable anti-aliasing. Anti-Aliasing is a technique used to improve the visual quality of images when displaying them on low resolution devices (for example, low DPI computer monitors).
Parameters:
Name Type Description
enable_aa boolean
Default Value:
  • Anti-aliasing is enabled by default.
Returns:
Type
Promise.<void>

setCaching( [enabled])

enables or disables caching. Caching can improve the rendering performance in cases where the same page will be drawn multiple times.
Parameters:
Name Type Argument Description
enabled boolean <optional>
if true PDFRasterizer will cache frequently used graphics objects.
Returns:
Type
Promise.<void>

setColorPostProcessMode(mode)

Set the color post processing transformation. This transform is applied to the rasterized bitmap as the final step in the rasterization process, and is applied directly to the resulting bitmap (disregarding any color space information). Color post processing only supported for RGBA output.
Parameters:
Name Type Description
mode number
PDFNet.PDFRasterizer.ColorPostProcessMode = {
	e_postprocess_none : 0
	e_postprocess_invert : 1
	e_postprocess_gradient_map : 2
	e_postprocess_night_mode : 3
}
is the specific transform to be applied
Returns:
Type
Promise.<void>

setDrawAnnotations(render_annots)

Enable or disable annotation and forms rendering. By default, annotations and forms are rendered.
Parameters:
Name Type Description
render_annots boolean True to draw annotations, false otherwise.
Returns:
Type
Promise.<void>

setDrawUIElements(draw_ui_elements)

Enable or disable drawing ui elements. Default is disabled.
Parameters:
Name Type Description
draw_ui_elements boolean true to draw ui elements, false otherwise.
Returns:
Type
Promise.<void>

setGamma(expgamma)

sets the gamma factor used for anti-aliased rendering.
Parameters:
Name Type Description
expgamma number is the exponent value of gamma function. Typical values are in the range from 0.1 to 3. Gamma correction can be used to improve the quality of anti-aliased image output and can (to some extent) decrease the appearance common anti-aliasing artifacts (such as pixel width lines between polygons). Note: Gamma correction is used only in the built-in rasterizer.
Returns:
Type
Promise.<void>

setHighlightFields(highlight)

Enable or disable highlighting form fields. Default is disabled.
Parameters:
Name Type Description
highlight boolean true to highlight, false otherwise.
Returns:
Type
Promise.<void>

setImageSmoothing( [smoothing_enabled] [, hq_image_resampling])

Enable or disable image smoothing. The rasterizer allows a tradeoff between rendering quality and rendering speed. This function can be used to indicate the preference between rendering speed and quality. Note: image smoothing option has effect only if the source image has higher resolution that the output resolution of the image on the rasterized page. PDFNet automatically controls at what resolution/zoom factor, 'image smoothing' needs to take effect.
Parameters:
Name Type Argument Description
smoothing_enabled boolean <optional>
True to enable image smoothing, false otherwise.
hq_image_resampling boolean <optional>
True to use a higher quality (but slower) smoothing algorithm
Default Value:
  • image smoothing is enabled and hq_image_resampling is false.
Returns:
Type
Promise.<void>

setOCGContext(ctx)

sets the Optional Content Group (OCG) context that should be used when rendering the page. This function can be used to selectively render optional content (such as PDF layers) based on the states of optional content groups in the given context.
Parameters:
Name Type Description
ctx Core.PDFNet.OCGContext Optional Content Group (OCG) context, or NULL if the rasterizer should render all content on the page.
Returns:
Type
Promise.<void>

setOverprint(op)

enable or disable support for overprint and overprint simulation. Overprint is a device dependent feature and the results will vary depending on the output color space and supported colorants (i.e. CMYK, CMYK+spot, RGB, etc).
Parameters:
Name Type Description
op number
PDFNet.PDFRasterizer.OverprintPreviewMode = {
	e_op_off : 0
	e_op_on : 1
	e_op_pdfx_on : 2
}
e_op_on: always enabled; e_op_off: always disabled; e_op_pdfx_on: enabled for PDF/X files only.
Default Value:
  • By default overprint is only enabled for PDF/X files.
Returns:
Type
Promise.<void>

setPathHinting(enable_hinting)

Enable or disable path hinting.
Parameters:
Name Type Description
enable_hinting boolean if true path hinting is enabled. Path hinting is used to slightly adjust paths in order to avoid or alleviate artifacts of hair line cracks between certain graphical elements. This option is turned on by default.
Returns:
Type
Promise.<void>

setPrintMode(is_printing)

tells the rasterizer to render the page 'print' mode. Certain page elements (such as annotations or OCG-s) are meant to be visible either on the screen or on the printed paper but not both. A common example, is the "Submit" button on electronic forms.
Parameters:
Name Type Description
is_printing boolean set to true is the page should be rendered in print mode.
Default Value:
  • By default, print mode flag is set to false.
Returns:
Type
Promise.<void>

setRasterizerType(type)

Sets the core graphics library used for rasterization and rendering. Using this method it is possible to quickly switch between different implementations. By default, PDFNet uses a built-in, high-quality, and platform independent rasterizer.
Parameters:
Name Type Description
type number
PDFNet.PDFRasterizer.Type = {
	e_BuiltIn : 0
	e_GDIPlus : 1
}
Rasterizer type. Note: This method is deprecated, since the GDI+ rasterizer itself is deprecated and will be removed in a future version of PDFNet. It is strongly recommended to use the built-in rasterizer and to use the XPS print path where vector conversion is needed.
Returns:
Type
Promise.<void>

setThinLineAdjustment(grid_fit, stroke_adjust)

Set thin line adjustment parameters.
Parameters:
Name Type Description
grid_fit boolean if true (horizontal/vertical) thin lines will be snapped to integer pixel positions. This helps make thin lines look sharper and clearer. This option is turned off by default and it only works if path hinting is enabled.
stroke_adjust boolean if true auto stroke adjustment is enabled. Currently, this would make lines with sub-pixel width to be one-pixel wide. This option is turned on by default.
Returns:
Type
Promise.<void>

takeOwnership()

Take the ownership of this object, so that PDFNet.runWithCleanup won't destroy this object.
Inherited From:
Returns:
Type
void

updateBuffer()

this function is typically called for progressive rendering, in which we don't want to stop the main rendering thread. Since the rendering thread may modify separation channels, we don't consider separations in progressive rendering.
Returns:
Type
Promise.<void>