|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.asprise.util.pdf.PDFImageWriter
An easy-to-use utility class that can create PDF document from images. Sample code:
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 Summary | |
PDFImageWriter(java.io.OutputStream outputStream)
Creates a writer with the specified target output stream. |
Method Summary | |
void |
addImage(java.io.File imageFile)
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 |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PDFImageWriter(java.io.OutputStream outputStream)
outputStream
- Method Detail |
public void addImage(java.lang.String imageFilePath) throws java.io.IOException
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.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
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |