Reading and writing support for PDF formats is included in the following Imaging SDK products:

  • Imaging SDK for the Java Platform

Reading or Decompressing a PDF Document

To read in or decompress a PDF document, use any of the decompression calls such as IMG_decompress_bitmap(String, int). All Imaging SDK products automatically detect the file format and do not use the extension on the file name.

The default size for decompressing PDF documents is 200 dots per inch (DPI) and 24 bits per pixel. To alter this or to convert PDF files, you can call the IMGLOW_set_pdf_input(int, int) method.

Page Manipulation

To extract, remove or rotate pages in a PDF document, use the functions below:

  • IMGLOW_delete_page(String name, int pageIndex, int[] error) Deletes the specified page from a multipage PDF document. Also has a duplicate taking a stream as an input parameter.
  • IMGLOW_extract_page(String name, int page, int[] error) Extracts the specified page from a PDF or TIFF document. Also has duplicates taking a stream and/or page range as input parameters.
  • IMGLOW_extract_rotated_page(String name, int page, int angle, int[] error) Same as IMGLOW_extract_page, but also has angle parameter. Also has duplicates taking a stream.

For these functions, you may want to switch to a newer internal PDF page manipulation engine by calling:

  • Snowbnd.setPdfParserBetaEnabled(true) (default: false) Set whether the newer PDF parsing will be enabled.

Saving to a PDF Document

Imaging SDK products support writing PDF files. To save a file as PDF, use any of the saving calls such as IMG_save_bitmap() with the file format set to PDF or the file type constant number 59.

RasterMaster Java can save to two different types of PDF files; raster PDF and vector PDF. IMG_save_bitmap(byte, int, int, int) saves a rasterized PDF with high fidelity rendering. IMG_save_document(byte, byte, int) outputs a vector PDF with text that can be searched so vector PDF is also known as searchable PDF. Currently, the text output is limited to ASCII.

Working with Black and White Images

If you are working with black and white documents, you will save a lot of memory and increase performance by setting the DPI to 300 or 200 and the bits per pixel to 1 when reading PDF images. For 1-bit or black and white images, will write out or save a PDF with CCITT - G4 compression for black and white images. For more information on improving performance, please see Improving Performance in Improving Performance or Quality.

Working with Color Images

For color bitmaps, a PDF will be created with JPEG compression.

Changing Output Page Size

The default page size is set to 8.5 x 11. The bitmap image saved is centered at this page. To alter the output page size, use the call the IMGLOW_set_pdf_output(int, int) method. The xsize and ysize parameters are the page size in points or 1/72 of an inch.

Performance

If you are working with black and white documents, you will save a lot of memory and increase performance by setting the DPI to 300 or 200 and the bits per pixel to 1 when reading all document formats. For more information on improving performance, please see Improving Performance in Improving Performance or Quality.

Methods Used for Vector PDF

The The VectorPDF sample demonstrates how to use vectorPDF. You can find the samples in the [RM Java install dir]\Samples\com\snowbound\samples directory. The methods used in this sample include:

  • IMG_decompress_bitmap(String, int) reads in a document in any format and converts it to a valid RasterMaster image. It displays the current image, corrected for aspect ratio, at the current X and Y coordinates.
  • IMG_display_bitmap_aspect(java.awt.Graphics,java.awt.Container, int, int, int, int, int) displays the current image, corrected for aspect ratio, at the current X and Y coordinates.
  • IMG_print_bitmap(java.awt.Graphics, int, int, int, int, int) prints the current image at the specified coordinates.

For the full method reference, please see the RasterMaster Java API.