Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4FB99FC1A for ; Mon, 25 Mar 2013 05:54:47 +0000 (UTC) Received: (qmail 12891 invoked by uid 500); 25 Mar 2013 05:54:47 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 12861 invoked by uid 500); 25 Mar 2013 05:54:46 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Delivered-To: moderator for users@pdfbox.apache.org Received: (qmail 87930 invoked by uid 99); 24 Mar 2013 22:48:52 -0000 X-ASF-Spam-Status: No, hits=-0.1 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of White.Ken@comcare.gov.au designates 163.233.3.14 as permitted sender) X-WSS-ID: 0MK6SNX-01-KMK-02 X-M-MSG: From: "Ken White" To: "users@pdfbox.apache.org" cc: "kwhite@kwcons.com" Subject: PDFBox Issue [SEC=UNCLASSIFIED] Thread-Topic: PDFBox Issue [SEC=UNCLASSIFIED] Thread-Index: Ac4mySF2GvJq3j93QKik2aT9vqFsOACF6I1AAAAxrpA= Date: Sun, 24 Mar 2013 22:48:03 +0000 Message-ID: Accept-Language: en-AU, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-classifier: janusSEAL for Outlook 2.6.2 x-protective-marking: VER=2012.3, NS=gov.au, SEC=UNCLASSIFIED, ORIGIN=white.ken@comcare.gov.au x-original-protective-marking: VER=2012.3, NS=gov.au, SEC=UNCLASSIFIED, ORIGIN=white.ken@comcare.gov.au x-originating-ip: [10.5.50.198] Content-Type: multipart/mixed; boundary=_004_B25883EAFD463943991C43200DFBB66B04C87C18PCBR01VEXMBX03c_ MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_004_B25883EAFD463943991C43200DFBB66B04C87C18PCBR01VEXMBX03c_ Content-Transfer-Encoding: 7bit Content-Type: multipart/alternative; boundary=_000_B25883EAFD463943991C43200DFBB66B04C87C18PCBR01VEXMBX03c_ --_000_B25883EAFD463943991C43200DFBB66B04C87C18PCBR01VEXMBX03c_ Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Here is the original file before modification by pdfbox. Ken =46rom: Ken White Sent: Monday, 25 March 2013 9:47 AM To: 'users@pdfbox.apache.org' Cc: kwhite@kwcons.com Subject: PDFBox Issue [SEC=3DUNCLASSIFIED] 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 =46rom: Ken White Sent: Friday, 22 March 2013 5:48 PM To: 'users@pdfbox.apache.org' Cc: kwhite@kwcons.com Subject: PDFBox Issue [SEC=3DUNCLASSIFIED] 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 =3D=3D 1) { ((AppPM) = getFacesPresentationManager()).setPdfDoc(null); deletePdfDoc(); } else { if (firstPage =3D=3D null || lastPage =3D=3D null) { setMessage(new AppException("You must specify th= e= first and last pages in the range!")); } else { PDDocument pdfDoc =3D ((AppPM) = getFacesPresentationManager()).getPdfDoc(); if (pdfDoc !=3D null) { int numPages =3D = 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 =3D false; // Delete the pages starting at th= e= last page in the range to avoid upsetting the page numbering for (int i =3D lastPage.intValue()= = - 1; i >=3D firstPage.intValue() - 1; i--) { if = (pdfDoc.getNumberOfPages() > 1) { pdfDoc.removePage(i); } else { // When there is onl= y= 1 page left just mark the document as empty isPdfDocEmpty =3D = true; } } if (isPdfDocEmpty) { ((AppPM) = getFacesPresentationManager()).setPdfDoc(null); deletePdfDoc(); } else { // Update the pdfDoc in the= = =66ile system try { = pdfDoc.save(pdfDocFileName); } catch (COSVisitorExceptio= n= 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. --------------------------------------------------------------------- --_000_B25883EAFD463943991C43200DFBB66B04C87C18PCBR01VEXMBX03c_ Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: quoted-printable

Here is the original = = =66ile 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=3DUNCLASSIFIED]

 

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
Subject: PDFBox Issue [SEC=3DUNCLASSIFIED]

 

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

 

 

  &nb= sp;    public= void removePages() throws= AppException = = {

  &nb= sp;           if= (pageRangeOpti= on =3D=3D 1) {

  &nb= sp;            =      = ((AppPM) getFacesPresentationManager()).setPdfDoc(null);

  &nb= sp;            =      = deletePdfDoc();

  &nb= sp;          = } else {

  &nb= sp;            =       if= (firstPage =3D=3D null || lastPage =3D=3D null) {

  &nb= sp;            =            = setMessage(new AppException("You mus= t= specify the first and last pages in the range!"));

  &nb= sp;            =      = } else {

  &nb= sp;            =            = PDDocument pdfDoc =3D ((AppPM) getFacesPresentationManager()).getPdfDoc();

  &nb= sp;            =             if= (pdfDoc !=3D null) {

  &nb= sp;            =             &nb= sp;      int numPages =3D = = pdfDoc.getNumberOfPages();

  &nb= sp;            =             &nb= sp;      if= (firstPage.intValue() < 1 || lastPage.intValue() = > numPages || firstPage.intValue() = > lastPage.intValue()) = = {

  &nb= sp;            =             &nb= sp;            = = setMessage(new AppException("The pag= e= range specified is invalid!"));

  &nb= sp;            =             &nb= sp;     = } else {

  &nb= sp;            =             &nb= sp;             boolean isPdfDocEmpty= = =3D false<= /b>;

  &nb= sp;            =             &nb= sp;             // Delete the= = pages starting at the last page in the range to avoid upsetting the page = numbering

  &nb= sp;            =             &nb= sp;             for = (int i =3D lastPage.intValue() - = = 1; i >=3D firstPage.intValue() - = = 1; i--) {

  &nb= sp;            =             &nb= sp;            =         if= = (pdfDoc.getNumberOfPages() > 1) {

  &nb= sp;            =             &nb= sp;            =             &nb= sp; = pdfDoc.removePage(i);

  &nb= sp;            =             &nb= sp;            =        = } else {

  &nb= sp;            =             &nb= sp;            =             &nb= sp;  // When there= = is only 1 page left just mark the document as empty

  &nb= sp;            =             &nb= sp;            =             &nb= sp; = isPdfDocEmpty =3D true;

  &nb= sp;            =             &nb= sp;            =        = }

  &nb= sp;            =             &nb= sp;            = = }

  &nb= sp;            =             &nb= sp;             if= = (isPdfDocEmpty) {

  &nb= sp;            =             &nb= sp;            =        = ((AppPM) getFacesPresentationManager()).setPdfDoc(null);

  &nb= sp;            =             &nb= sp;            =        = deletePdfDoc();

  &nb= sp;            =             &nb= sp;            = = } else {

  &nb= sp;            =             &nb= sp;            =         // Update the= = pdfDoc in the file system

  &nb= sp;            =             &nb= sp;            =         try {

  &nb= sp;            =             &nb= sp;            =             &nb= sp; = pdfDoc.save(pdfDocFileNam= e);

  &nb= sp;            =             &nb= sp;            =        = } catch<= /b> = (COSVisitorException error) {

  &nb= sp;            =             &nb= sp;            =             &nb= sp;  throw<= /b> new = AppException(error.getMessage());

  &nb= sp;            =      = =             &nb= sp;            =  = } catch<= /b> (IOException = = error) {

  &nb= sp;            =             &nb= sp;            =             &nb= sp;  throw<= /b> new = AppException(error.getMessage());

  &nb= sp;            =             &nb= sp;            =        = }

  &nb= sp;            =             &nb= sp;            = = }

  &nb= sp;            =             &nb= sp;     = }

  &nb= sp;            =            = } else {

  &nb= sp;            =             &nb= sp;     = setMessage(new AppException("The pdf= = document is empty!"));

  &nb= sp;            =            = }

  &nb= sp;            =      = }

  &nb= sp;          = }

  &nb= sp;   = }

 

 

The original file is read by pdfbox and adobe withou= t= 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.
---------------------------------------------------------------------<= br/>

--_000_B25883EAFD463943991C43200DFBB66B04C87C18PCBR01VEXMBX03c_-- --_004_B25883EAFD463943991C43200DFBB66B04C87C18PCBR01VEXMBX03c_--