public class PDFImageWriter
extends java.lang.Object
PDFImageWriter writer = new PDFImageWriter(new FileOutputStream("new.pdf"));
writer.open();
writer.addImage("C:\\1.jpg");
writer.addImage("C:\\2.png");
writer.close();
System.out.println("DONE.");
PDFImageWriter.saveImagesToPDF(new File[]{ new File("C:\\1.jpg"), new File("C:\\2.png") }, new File("new.pdf");
PDFImageWriter.saveImagesToPDF(new Image[]{image1, image2}, new File("new.pdf");
PDFSecurityObject so = new PDFSecurityObject();
so.ownerPassword = "LAB Asprise";
so.userPassword = "user";
so.permissions = PDFSecurityObject.PERMISSION_PRINTING | PDFSecurityObject.PERMISSION_COPY; // allow printing and copying.
PDFImageWriter writer = new PDFImageWriter(new FileOutputStream("new.pdf"));
writer.setPDFSecurityObject(so);
writer.open();
writer.addImage("C:\\1.jpg");
writer.close();
Constructor and Description |
---|
PDFImageWriter(java.io.OutputStream outputStream)
Creates a writer with the specified target output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
addImage(java.io.File imageFile)
Adds the given image as a PDF page.
|
void |
addImage(java.io.File imageFile,
java.lang.String annotationText)
Adds the given image as a PDF page.
|
void |
addImage(java.awt.Image image)
Adds the given image as a PDF page.
|
void |
addImage(java.lang.String imageFilePath)
Adds the given image as a PDF page.
|
void |
addImage(java.lang.String imageFilePath,
java.lang.String annotationText)
Adds the given image as a PDF page.
|
void |
close()
Signal the writer to write content to the target output stream and close the writer.
|
PDFSecurityObject |
getPdfSecurityObject()
Returns the PDF security object used.
|
static void |
main(java.lang.String[] args)
A utility that save images into PDF file.
|
void |
open()
Opens the writer for adding contents.
|
static void |
saveImagesToPDF(java.io.File[] sourceImages,
java.io.File targetPDFile)
Saves the given images into the specified PDF file.
|
static void |
saveImagesToPDF(java.awt.Image[] sourceImages,
java.io.File targetPDFile)
Saves the given images into the specified PDF file.
|
void |
setPDFSecurityObject(PDFSecurityObject pdfSecurityObject)
Sets the PDF security to be used - you need to set security object before close()
otherwise it will be ignored.
|
public PDFImageWriter(java.io.OutputStream outputStream)
outputStream
- public void addImage(java.lang.String imageFilePath) throws java.io.IOException
imageFilePath-
- this image file.java.io.IOException
public void addImage(java.lang.String imageFilePath, java.lang.String annotationText) throws java.io.IOException
imageFilePath-
- this image file.annotationText
- optional text to be displayed as PDF annotation.java.io.IOException
public void addImage(java.io.File imageFile) throws java.io.IOException
imageFile
- - this image file.java.io.IOException
public void addImage(java.io.File imageFile, java.lang.String annotationText) throws java.io.IOException
imageFile
- - this image file.java.io.IOException
public void addImage(java.awt.Image image)
public void open()
public void close()
public static void saveImagesToPDF(java.io.File[] sourceImages, java.io.File targetPDFile) throws java.io.IOException
sourceImages
- - Supported images formats are: GIF, PNG, BMP, JPEG.targetPDFile
- java.io.IOException
public static void saveImagesToPDF(java.awt.Image[] sourceImages, java.io.File targetPDFile) throws java.io.IOException
sourceImages
- targetPDFile
- java.io.IOException
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- java.lang.Exception
public PDFSecurityObject getPdfSecurityObject()
public void setPDFSecurityObject(PDFSecurityObject pdfSecurityObject)
pdfSecurityObject
-