How to compress black and white image into PDF file with command line

The command line application PDF OCR Compressor allows you to compress black and white image into PDF file on Windows platforms.

PDF OCR Compressor is a powerful command line application that can be used both as a PDF creator and a PDF compressor. As a PDF creator, it can convert JPG, PNG, BMP, GIF, TIF, PSD, WMF, EMF, PCX, PIC, etc. format image to PDF file. As a PDF compressor, it can compress black and white, color, and grayscale images during the conversion from image to PDF.

In the following contents, you will see how to use this application to compress black and white image into PDF file.

1. Download and unzip

Please download the package of PDF OCR Compressor and unzip it to a place on your computer. In the unzipped folder, you can see an executable file—pdfocrjb2.exe and it is the called program in the MS-DOS command prompt window.

2. Type commands

To type commands, you need to open the command prompt window first. In the opened command prompt window, please type your commands referring to the following command line template.

img2pdf [options] <Image-file> [<PDF-file>]

  • img2pdf: call the program—pdfocrjb2.exe.
  • [options]: set options for the conversion.
  • <Image-file>: specify the input image.
  • [<PDF-file>]: specify the output PDF file.

To compress the black and white image, please use the option:-bwimg <int> which is used to set compression method for black and white image. It can be one of the following:

  • -bwimg 0: no change compression for black and white image file
  • -bwimg 1: compress black and white image file with CCITT G4 arithmetic
  • -bwimg 2: compress black and white image file with JBIG2 arithmetic

For example,

F:\pdfocrjb2\pdfocrjb2.exe -bwimg 1 “F:\juice.png” “D:\ juice.pdf”

F:\pdfocrjb2\pdfocrjb2.exe-bwimg 2 “E:\work.jpg” “F:\work.pdf”

The first example is to compress the black and white image —juice.png with CCITT G4 arithmetic and convert the PNG image to juice.pdf. The second example is to compress the black and white image—work.jpg with JBIG2 arithmetic and convert the JPG image to work.pdf.

After typing the commands, please hit Enter button on your keyboard to run the commands.

Several seconds later, you can see the created PDF in the specified location.

This is the end of this article and you can get full version of PDF OCR Compressor here.

Related Posts: