List of usage examples for com.lowagie.text.pdf PdfReader setPageContent
public void setPageContent(int pageNum, byte content[])
From source file:net.sf.jsignpdf.UncompressPdf.java
License:Mozilla Public License
/** * The main 'main'.//ww w . j a v a2s .c o m * * @param args */ public static void main(String[] args) { if (args == null || args.length == 0) { System.out.println("Usage:\njava " + UncompressPdf.class.getName() + " file.pdf [file2.pdf [...]]"); return; } Document.compress = false; for (String tmpFile : args) { String newFileName = null; if (tmpFile.toLowerCase().endsWith(".pdf")) { newFileName = tmpFile.substring(0, tmpFile.length() - 4) + "_uncompressed.pdf"; } else { newFileName = tmpFile + "_uncompressed.pdf"; } System.out.println("Uncompressing " + tmpFile + " to " + newFileName); try { PdfReader reader = new PdfReader(tmpFile); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(newFileName), '\0'); int total = reader.getNumberOfPages() + 1; for (int i = 1; i < total; i++) { reader.setPageContent(i, reader.getPageContent(i)); } stamper.close(); } catch (NullPointerException npe) { npe.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }