By default, PDF2Image saves rasterized files in the current working folder. To specify another output location, use the '-o' (or --output) parameter. For example:
pdf2image --o "c:\My Output" 1.pdf 2.pdf 3.pdf
Note: If the specified path does not exist, PDF2Image will attempt to create the necessary folders.
By default, PDF2Image creates a separate image file for every page in the document. The output filename is constructed using the name of the input PDF file, page counter, and appropriate image extension. For example, the following command-line generates a sequence of image files starting with mydoc_1.jpg, mydoc_2.jpg, etc.:
pdf2image -f jpg mydoc.pdf
PDF2Image allows output filename customizations using the '--prefix' and '--digits' options. For example, the following command-line generates a sequence of image files starting with newname_0001.jpg, newname_0002.jpg, etc.:
pdf2image -f jpg --prefix newname --digits 4 mydoc.pdf
The '--digits' parameter specifies the number of digits used in the page counter portion of the output filename. By default, new digits are added as needed, however this parameter could be used to format the page counter field to a uniform width (e.g. myfile0001.jpg, myfile0010.jpg, instead of myfile_1.jpg, myfile_10.jpg, etc).
To avoid any ambiguities in file naming, the prefix option should be used only for conversion of individual documents.
If your output image format is TIFF, you can convert PDF to a single, multi-page TIFF document using the '--multipage' option (See 'How do I convert PDF to multi-page TIF?' for an example).
By default, PDF2Image automatically converts PDF to PNG. The output image format can be modified using the '-f' (or --format) option. For example,
pdf2image -f jpg in.pdf
will convert PDF to JPEG.
The '--format' parameter accepts any of the following output formats:
If your output image format is TIFF, you can convert PDF to a single, multi-page TIFF document instead of a separate file for every page using the '--multipage' option.
For example:
pdf2image --multipage -f tif --verb 3 mypdf.pdf
PDF2Image will, without user intervention, decrypt and convert documents secured with a master/owner password. If the document is secured using a user (or file open) password, PDF2Image will prompt you to enter the password.
For unattended conversion, the password can also be specified directly on the command-line using the '-p' (or --password) option. For example:
pdf2image -p secret -f png secured.pdf
The above command line will convert PDF to PNG and will use the provided password ('secret') to open the secured document (i.e. 'secured.pdf').
Note: PDF2Image supports all standard security options available in PDF, including 40 and 128 bit RC4 encryption, Crypt filters, and 128 AES (Advanced Encryption Standard) encryption.
By default, PDF2Image uses the RGB color model for rasterization and image export. You can instruct PDF2Image to use single channel Device Gray color model for rasterization and image export using the '--gray' option. For example:
pdf2image -f tiff --gray in.pdf
By default, PDF2Image will rasterize and convert all PDF pages to output image format. You can specify a subset of pages to convert using the '-a' or '--pages' options. For example:
pdf2image -a 1,3,10 in.pdf
will convert only pages 1, 3, and 10. Please note that PDF2Image assumes that all pages are numbered sequentially starting from page 1.
To specify a range of pages, use dash character between numbers. For example:
pdf2image -a 1,10-20,50- in.pdf
will render the first page, pages in the range from 10 to 20 and all pages starting with page 50 to the last page in the document.
All even pages can be selected using the 'e' (or 'even') string. For example, the following line renders all even pages:
pdf2image --pages even in.pdf
Similarly odd pages can be selected using the 'o' (or 'odd') string. The following line renders all odd pages in the document and every page in the range from 100 to the last page:
pdf2image --pages odd,100- in.pdf
Using PDF2Image output image resolution can be specified explicitly (using the '--d' or '--dpi' option) or implicitly (using the '--hres' and '--vres' parameters). In this section, we cover the use of the '--dpi' parameter. For more information on the '--hres' and '--vres' parameters, see 'How do I specify dimensions of the output image in pixels?'
By default, PDF2Image uses resolution of 92 Dots Per Inch (DPI), which is the typical screen resolution. Smaller DPI numbers result in smaller images (e.g. suitable for use as thumbnails), while larger DPI numbers generate larger images (e.g. suitable for high-quality output).
For example, to convert a PDF document to a multi-page TIF at 300 DPI (Dots Per Inch), use the following line:
pdf2image -f tif --multipage --dpi 300 in.pdf
Depending on the dimensions of the input page, high DPI/resolution rasterization requires lots of memory. For example, rasterization of a single A4 page (8x11) at 1000 DPI will require more than 350MB of memory. If PDF2Image fails to allocate enough memory, you can render the image in stripes or tiles, as described in 'How do I render high-resolution images', or by trying to decrease DPI value.
A 'typical' range of acceptable DPI values is between 1 and 1000 DPI. PDF2Image can rasterize images beyond 1000 or 2000 DPI using tiled or striped rendering.
To specify absolute dimensions of the output image in pixels, use the '--hres' and '--vres' parameters.
When these parameters are specified, PDF2Image will automatically determine the DPI (Dots Per Inch) ratio required to match the pixel dimensions of the output image.
For example, to generate 100 by 100 pixels thumbnails for a given PDF, you can use the following line:
pdf2image -f jpg --hres 100 --vres 100 in.pdf
Because the input PDF page may not perfectly fit the absolute pixel size of the output image, PDF2Image will also center the page and preserve the aspect ratio during rendering.
To generate images that are proportional in their size to the input PDF pages, simply omit one of the parameters (either --hres or --vres). For example,
pdf2image -f jpg --hres 100 in.pdf
will convert all PDF pages to images that are 100 pixels wide, with height proportional to the dimensions of the input page.
Similarly, the following line will create images with fixed height (100 pixels) and variable width (to preserve the aspect ratio).
pdf2image -f jpg --vres 100 in.pdf
Using PDF2Image you can rasterize a subset of a page using the '--clip' parameter. The parameter accepts a list of four numbers, separated using commas, giving the coordinates of a pair of diagonally opposite corners. Typically, the list takes the form: llx, lly, urx, ury specifying the lower-left x, lower-left y, upper-right x, and upper-right y coordinates of the rectangle, in that order. The other two corners of the rectangle are then assumed to have coordinates (llx, ury) and (urx, lly). All coordinates need to be expressed in points (a basic unit of PDF 'user' coordinate system). One PDF point is 1⁄72 of an inch and is approximately the same as a point (unit commonly used in the printing industry).
The '--clip' parameter is not only useful for cropping pages, but it can be also used to speed up the rendering process and to reduce memory consumption (see 'How to I render very large images?' for details).
PDF2Image also supports clipping to predefined page regions, such as page media, crop, trim, bleed, and art box. For more information on clipping to predefined regions, see 'How can I show/hide crop marks or the trim region?
Depending on the dimensions of the input page, high DPI/resolution rasterization requires lots of memory. For example, rasterization of a single A4 page (8x11) at 1000 DPI will require more than 350MB of memory. If PDF2Image fails to allocate enough memory (a single contiguous block of memory), you can render the image in stripes or tiles by repeatedly rendering different regions of the page using the '--clip' parameter (also see 'How do I render only a subset of a given page?').
For example, if the input page has a media box 0,0,595,842, you could render the page at 2000 DPI (Dots Per Inch) in four stripes (using 210.5 point increments along the Y axis) as follows:
pdf2image --dpi 2000 --clip 0,0,595,210.5 --prefix t01 Test/tiger.pdf
pdf2image --dpi 2000 --clip 0,210.5,595,421 --prefix t02 Test/tiger.pdf
pdf2image --dpi 2000 --clip 0,421,595,631.5 --prefix t03 Test/tiger.pdf
pdf2image --dpi 2000 --clip 0,631.5,595,842 --prefix t04 Test/tiger.pdf
Rendering of the same image in a single pass would require more than 1.4 GB in memory.
PDF2Image supports batch conversion of many PDF files in a single pass. To convert all PDF files in a given folder(s) you can use the following syntax:
pdf2image myfolder1
The '--subfolders' option can be used to recursively process all subfolders. For example, the following line will convert all documents in 'myfolder1' and 'myfolder2' as well as all subfolders:
pdf2image --subfolders myfolder1 myfolder2
By default, PDF2Image will convert all files with the extension '.pdf'. To select different files based on the extension use the '--extension' parameter. For example, to convert all PDF documents with a custom extension '.blob', you could use the following line:
pdf2image --extension .blob --subfolders myfolder1
The JPEG image format offers a lossy type of compression and the option to trade between the loss in image quality and compression ratio. To fine-tune JPEG compression quality, use the '--quality' parameter as illustrated in the following sample:
pdf2image --quality 80 -f jpg Test/tiger.pdf
Compression quality is a number in the range from 1 to 100. Lower numbers usually result in better compression at the expense of image quality. The default in 80.
By default, PDF2Image respects page rotation attribute. Image rotation can be modified using the '-r' (or --rotate) option. For example, the following line rotates all pages 90 degrees counterclockwise:
pdf2image --rotate 90 Test/tiger.pdf
Similarly, the following line rotates the page 270 degrees counterclockwise (or 90 degrees clockwise):
pdf2image --rotate 270 Test/tiger.pdf
A PDF page can define as many as five separate boundaries to control various aspects of the imaging process:
By default, PDF2Image uses the page crop box as a default clip region. Different page regions can be selected as the default clip region using the -b (or --box) parameter. For example, the following line will instruct PDF2Image to use the media box for rasterization:
pdf2image --box media in.pdf
To render the PDF as a monochrome (1 bit per pixel) image compressed using G4 CCITT, simply add the option '--mono' within the command-line string. For example,
pdf2image --mono -f TIFF --verb 10 --dpi 300 in.pdf
PDF2Image is a completely stand alone application and does not include any dependencies on third-party components or software.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales