For PNG the pdf file size should be approximatly the sum of
the PNG sizes. Acrobat may be downscaling the images.
Best Regards,
Paulo Soares
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, March 23, 2004 7:59 PM
To: [EMAIL PROTECTED]
Subject: [iText-questions] Compression Issue
I'm noticing what seems to be a compression problem. I'm making a pdf from 48 PNGs with itext, and I am getting a file about 54mb. A PDF created with the same PNGs in Acrobat is only about 10mb. I tried turning on the compression flag, which didn't have an effect. Here is my code:
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import java.io.*;
import java.util.*;
public class Utilities {
boolean debug = true;
public static void convert2Pdf(ArrayList files, String outputFile) {
try {
Rectangle r = new Rectangle(792, 612);
Document document = new Document(r, 0.0F, 0.0F, 0.0F, 0.0F);
document.compress = true;
PdfWriter.getInstance(document, new FileOutputStream(outputFile));
document.open();
for (int i = 0; i < files.size(); ++i) {
Image image = Image.getInstance((String)files.get(i));
image.scaleToFit(792,612);
document.add(image);
}
document.close();
}catch (Exception e) {
System.err.println("ERROR Utilities: Pdf could not be made from images");
e.printStackTrace();
}
}
/**
* If debug flag is set print out object.
* @param output object to output
*/
private void debug(Object output) {
if (debug) {
System.out.println(output);
}
}
}
Thanks in advance.
-Michael Christoff
