RawImageOutput Device¶
RawImageOutput¶
-
class
pyxpdf.xpdf.
RawImageOutput
¶ Render PDF page as Image.
Convert the PDF page to uncompressed raw image.
paper_color depends on the color mode of image, if color mode is RGB or RGBA than paper_color should be a 3 int(0-255) tuple of RGB values, similarly for CMYK it should be 4 int(0-255) tuple of CMYK color values.
If you are using image mode with alpha channel and want transparent background then set no_composite to True
- Parameters
doc (Document) – PDF Document for this output device
mode ({"RGB", "RGBA", "L", "LA", "1", "CMYK"}, optional) – image modes for output rendered image, equivalent to Pillow’s image modes. (default is ‘RGB’)
paper_color (tuple of int, optional) – paper color for rendered pdf page (default is
None
, means ‘white’ paper color)resolution (float, optional) – X and Y resolution of output image in DPI (default is 150)
resolution_x (float, optional) – X resolution in DPI (default is 150)
resolution_y (float, optional) – X resolution in DPI (default is 150)
anti_alias (bool, optional) – enable font anti-aliasing for rendering (default is True)
no_composite (bool, optional) – disables the final composite (with the opaque paper color), resulting in transparent output. (default is False)
use_cropbox (bool, optional) – use the crop box rather than media box (default is False)
scale_before_rotation (bool, optional) – resize dimensions before rotation of rotated pdfs (default is False)
Note
Additionally you can enable
Config.vector_anti_alias
for better anti-alias effect.Warning
Avoid ‘1’ image mode, as of now its quite buggy and fonts are not rendered properly in it. Instead use ‘L’ for black and white.
-
get
(self, int page_no, crop_box=(0, 0, 0, 0), scale_pixel_box=None)¶ Get the rendered
Image
for page_no indexed page- Parameters
- Returns
Rendered PDF Page
- Return type
Note
Requires Optional dependency
Pillow
module
-
resolution_x
¶ ‘double’
- Type
resolution_x
-
resolution_y
¶ ‘double’
- Type
resolution_y
-
scale_before_rotation
¶ ‘bool’
- Type
scale_before_rotation
-
use_cropbox
¶ ‘bool’
- Type
use_cropbox