pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken White" <White....@comcare.gov.au>
Subject PDFBox Issue [SEC=UNCLASSIFIED]
Date Sun, 24 Mar 2013 22:48:03 GMT
Here is the original file before modification by pdfbox.

Ken

From: Ken White
Sent: Monday, 25 March 2013 9:47 AM
To: 'users@pdfbox.apache.org'
Cc: kwhite@kwcons.com
Subject: PDFBox Issue [SEC=UNCLASSIFIED]

Hi The message below was rejected by the apache server because the attachments were > 1MB.
 So here is it again with the file AFTER modification with pdfbox.  I will forward the original
in a second email.

Regards
Ken

From: Ken White
Sent: Friday, 22 March 2013 5:48 PM
To: 'users@pdfbox.apache.org'
Cc: kwhite@kwcons.com<mailto:kwhite@kwcons.com>
Subject: PDFBox Issue [SEC=UNCLASSIFIED]

Hi

I am not sure if this is the right forum to raise this, but I have an issue with pdfbox. 
I get the following from adobe reader 10.1.0 if I try to open a PDF that has had pages removed
by pdfbox.

The document's page tree contains an invalid node.

Here is the code I am using


       public void removePages() throws AppException {
              if (pageRangeOption == 1) {
                     ((AppPM) getFacesPresentationManager()).setPdfDoc(null);
                     deletePdfDoc();
              } else {
                     if (firstPage == null || lastPage == null) {
                           setMessage(new AppException("You must specify the first and last
pages in the range!"));
                     } else {
                           PDDocument pdfDoc = ((AppPM) getFacesPresentationManager()).getPdfDoc();
                           if (pdfDoc != null) {
                                  int numPages = pdfDoc.getNumberOfPages();
                                  if (firstPage.intValue() < 1 || lastPage.intValue() >
numPages || firstPage.intValue() > lastPage.intValue()) {
                                         setMessage(new AppException("The page range specified
is invalid!"));
                                  } else {
                                         boolean isPdfDocEmpty = false;
                                         // Delete the pages starting at the last page in
the range to avoid upsetting the page numbering
                                         for (int i = lastPage.intValue() - 1; i >= firstPage.intValue()
- 1; i--) {
                                                if (pdfDoc.getNumberOfPages() > 1) {
                                                       pdfDoc.removePage(i);
                                                } else {
                                                       // When there is only 1 page left just
mark the document as empty
                                                       isPdfDocEmpty = true;
                                                }
                                         }
                                         if (isPdfDocEmpty) {
                                                ((AppPM) getFacesPresentationManager()).setPdfDoc(null);
                                                deletePdfDoc();
                                         } else {
                                                // Update the pdfDoc in the file system
                                                try {
                                                       pdfDoc.save(pdfDocFileName);
                                                } catch (COSVisitorException error) {
                                                       throw new AppException(error.getMessage());
                                                } catch (IOException error) {
                                                       throw new AppException(error.getMessage());
                                                }
                                         }
                                  }
                           } else {
                                  setMessage(new AppException("The pdf document is empty!"));
                           }
                     }
              }
       }


The original file is read by pdfbox and adobe without error.  I have attached both files.
 I am happy to provide any other details if needed.

TIA
Ken


---------------------------------------------------------------------

NOTICE: This e-mail message and attachments may contain confidential information. If you are
not the intended recipient you should not use or disclose any information in the message or
attachments. If received in error, please notify the sender by return email immediately. 
Comcare does not waive any confidentiality or privilege.

---------------------------------------------------------------------


Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message