How to Make the PDF document compressable Using java and iText Library?.
Use this Flag while creating PDFDocument
Document.compress = true;
writer.setPdfVersion('1.6');
writer.setFullCompression();
Sample Code for Compression to make File Size Lesser (PDF File previously not compressed one)
public class SampleCompress
{
public static void main(String[] args)
{
try
{
PdfReader reader = new PdfReader("D:\\temp\\temp.pdf");
PdfStamper stamper = new PdfStamper(reader,
new FileOutputStream("D:\\temp\\temp_compress.pdf"),
PdfWriter.VERSION_1_6);
stamper.setFullCompression();
stamper.close();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
}
}
}
No comments:
Post a Comment