9.7.  Extract Images from PDF

This utility extracts images imbedded in PDF document to PNG images. Each image is written to a separate file. Tests with those images are described in section 3.13: “Images in PDF Documents”.

Program Start

::
:: Extract all images of a PDF document into a PNG file for each image.
::

@echo off
setlocal
set CLASSPATH=./lib/pdfunit-2015.10/*;%CLASSPATH%
set CLASSPATH=./lib/itext-5.5.1/*;%CLASSPATH%
set CLASSPATH=./lib/bouncycastle-jdk15on-150/*;%CLASSPATH%

set TOOL=com.pdfunit.tools.ExtractImages
set OUT_DIR=./tmp
set IN_FILE=imageDemo.pdf
set PASSWD=

java  %TOOL%  %IN_FILE%  %OUT_DIR%  %PASSWD%
endlocal

Input

The input file imageDemo.pdf contains two images:

Output

After running the utility, two files are created:

# created images:

.\tmp\_exported-image_imageDemo_4.out.png   1
.\tmp\_exported-image_imageDemo_12.out.png  2

1 2

The number in the file name is the object number within the PDF document.