Top Description Constructors Methods
org.apache.pdfbox.examples.pdmodel

public Class AddImageToPDF

extends Object
Class Inheritance
Imports
java.io.File, .IOException, org.apache.pdfbox.Loader, org.apache.pdfbox.pdmodel.PDDocument, .PDPage, .PDPageContentStream, .PDPageContentStream.AppendMode, org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject

This is an example that creates a reads a document and adds an image to it.. The example is taken from the pdf file format specification.
Author
Ben Litchfield

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
createPDFFromImage(String
The input PDF to add the image to.
inputFile
,
String
The filename of the image to put in the PDF.
imagePath
,
String
The file to write to the pdf to.
outputFile
)

Add an image to an existing PDF document.

public static void
main(String[]
Command line arguments.
args
)

This will load a PDF document and add a single image on it.

private void
usage()

This will print out a message telling how to use this example.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AddImageToPDFback to summary
public AddImageToPDF()

Method Detail

createPDFFromImageback to summary
public void createPDFFromImage(String inputFile, String imagePath, String outputFile) throws IOException

Add an image to an existing PDF document.

Parameters
inputFile:String

The input PDF to add the image to.

imagePath:String

The filename of the image to put in the PDF.

outputFile:String

The file to write to the pdf to.

Exceptions
IOException:
If there is an error writing the data.
mainback to summary
public static void main(String[] args) throws IOException

This will load a PDF document and add a single image on it.
see usage() for commandline

Parameters
args:String[]

Command line arguments.

usageback to summary
private void usage()

This will print out a message telling how to use this example.