Earnie Dyke wrote:

You can use the java.util.jar classes to unzip and zip files.

That was not the question I think.

UNCOMPRESS (DANGEROUS!)
PdfReader reader = new PdfReader("HelloWorld.pdf");
PdfStamper stamper =
new PdfStamper(reader, new FileOutputStream("HelloWorldUncompressed.pdf"), '1');
Document.compress = false;
int total = reader.getNumberOfPages() + 1;
for (int i = 1; i < total; i++) {
 reader.setPageContent(i, reader.getPageContent(i));
}
stamper.close();
This is dangerous because of the line Document.compress = false;
this is a static value, so as soon as you set it to false, all the
documents you are generating in the same JVM will not be compressed.
Notice that I have also set the PDF version to 1.1 (not necessary).

COMPRESSION:
PdfReader reader = new PdfReader("HelloWorldUncompressed.pdf");
PdfStamper stamper =
 new PdfStamper(reader, new FileOutputStream("HelloWorldCompressed.pdf"));
stamper.close();

FULL COMPRESSION
PdfReader reader = new PdfReader("HelloWorldCompressed.pdf");
PdfStamper stamper =
new PdfStamper(reader, new FileOutputStream("HelloWorldFullCompression.pdf"),
 PdfWriter.VERSION_1_5);
stamper.setFullCompression();
stamper.close();
Notice that I have set the version number to 1.5, because
full compression didn't exist in previous versions.

br,
Bruno


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to