> is it possible to re-open a pdf file as save it in different parts ?
> In my cas, I will produce a full pdf document but in some 
> cases, I would like to re-open it and save only a few number 
> of pages in a new pdf file.

Hi Paul,

Have a look at my "getPage"-Method.
Maybe it's helpfull for you.

/*get the page (by number) from the existing Pdf and write it to the
destination*/
public File getPage(int number, String destFolder) {
    try {
      log.debug("getpage: " + number + " --> " + destFolder);
      Document document = new
Document(reader.getPageSizeWithRotation(number));
      File f = new File(destFolder + number + ".pdf");
      log.debug("fname: " + f.getAbsolutePath());
      log.debug("exist: " + f.exists());
      PdfWriter writer = PdfWriter.getInstance(document,
          new FileOutputStream(f));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      document.newPage();
      PdfImportedPage page = writer.getImportedPage(reader, number);
      cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
      document.close();
      writer.close();
      return f;
    } catch (DocumentException e) {
      log.error("Document Error", e);
    } catch (FileNotFoundException e) {
      log.error("IO Error", e);
    }
    return null;
  } 






-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to