You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Amber Prakash Verma <am...@newgensoft.com.INVALID> on 2024/02/27 07:55:57 UTC

Issue with PDFBox 3.0.0 - Unable to Extract and Add Pages

Dear PDFBox Team,

I hope this email finds you well. I am writing to report an issue I encountered while using PDFBox version 3.0.0. It appears that there is a problem when attempting to extract pages from one PDF and add them to another PDF.
While using the same code and PDFBox version 2.0.29, it is perfectly working and output PDF contains no blank pages.

Issue Description:

  *
Version: PDFBox 3.0.0
  *
Problem: When using the PDFBox library to extract pages from one PDF file and add them to another PDF or a new PDF file, the resulting document contains blank pages.


Steps to Reproduce:

  *
Load an existing PDF document.
  *
Extract pages from document.
  *
Add the extracted Pages to a new PDF.
  *
Save the modified PDF.

Expected Result:
The resulting PDF should contain the extracted pages without any blank content.

Actual Result:
The resulting PDF contains blank pages.

Additional Information:

  *
I have attached the code snippet that reproduces the issue
  *
I am using the following dependencies.
PDFBox version 3.0.0
Java Version - 1.8.0_91


Code Snippet:
​```
       try{
          for (int i = 1; i < iDestPageNumber; i++)
          {
             PDPage page = destReader.getPage(i-1);
             page.setMediaBox(destReader.getPage(i-1).getMediaBox());
             page.setResources(destReader.getPage(i-1).getResources());
             tempDocument.addPage(page);
             iOutputPageCount++;
          }

          int srcPages = srcReader.getNumberOfPages();
          for (int i = 0; i < srcPages; i++)
          {                                         
             PDPage page = srcReader.getPage(i);
             page.setMediaBox(srcReader.getPage(i).getMediaBox());
             page.setResources(srcReader.getPage(i).getResources());
             tempDocument.addPage(page);
             iOutputPageCount++;
          }

          for (int i =iDestPageNumber; i <= destPages; i++)
          {
             PDPage page = destReader.getPage(i-1);
             page.setMediaBox(destReader.getPage(i-1).getMediaBox());
             page.setResources(destReader.getPage(i-1).getResources());
             tempDocument.addPage(page);
             iOutputPageCount++;
         }
           tempDocument.save(outputPath);
             tempDocument.close();
}
```

I would appreciate any guidance, suggestions, or potential solutions to resolve this issue. If this is a known problem, please let me know if there are any workarounds or if a fix is planned in a future release.

Thank you for your time and assistance. I appreciate the hard work you put into maintaining the PDFBox library.

Best regards,

Amber Prakash Verma
amber.vema@newgensoft.com
Newgen Software





Disclaimer: This e-mail and any attachment may contain confidential, proprietary or legally privileged information. If you are not the original intended recipient and have erroneously received this message, you are prohibited from using, copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender. Newgen Software Technologies Ltd (NSTL) accepts no responsibilities for loss or damage arising from the use of the information transmitted by this email including damages from virus and further acknowledges that no binding nature of the message shall be implied or assumed unless the sender does so expressly with due authority of NSTL.

Re: Issue with PDFBox 3.0.0 - Unable to Extract and Add Pages

Posted by Andreas Lehmkühler <an...@lehmi.de.INVALID>.
The issue was fixed and is part of the current 3.0.2 version of PDFBox.

Andreas

Am 27.02.24 um 10:11 schrieb Tilman Hausherr:
> Hi,
> 
> It's like Fabian said.
> 
> Btw neither the code here nor the different(!) code in 
> https://stackoverflow.com/questions/78065676/ would enable anybody to 
> reproduce such a bug because it's incomplete.
> 
> Until we get this fixed, please stay with 2.0.* (2.0.30 is the current 
> version), and also update your jdk, 1.8.0_91 is from 2016. The current 
> version is 1.8.0_402.
> You can also try a snapshot here from time to time:
> https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/3.0.2-SNAPSHOT/
> Tilman
> 
> On 27.02.2024 08:55, Amber Prakash Verma wrote:
>> Dear PDFBox Team,
>>
>> I hope this email finds you well. I am writing to report an issue I 
>> encountered while using PDFBox version 3.0.0. It appears that there is 
>> a problem when attempting to extract pages from one PDF and add them 
>> to another PDF.
>> While using the same code and PDFBox version 2.0.29, it is perfectly 
>> working and output PDF contains no blank pages.
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Issue with PDFBox 3.0.0 - Unable to Extract and Add Pages

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

It's like Fabian said.

Btw neither the code here nor the different(!) code in 
https://stackoverflow.com/questions/78065676/ would enable anybody to 
reproduce such a bug because it's incomplete.

Until we get this fixed, please stay with 2.0.* (2.0.30 is the current 
version), and also update your jdk, 1.8.0_91 is from 2016. The current 
version is 1.8.0_402.
You can also try a snapshot here from time to time:
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/3.0.2-SNAPSHOT/
Tilman

On 27.02.2024 08:55, Amber Prakash Verma wrote:
> Dear PDFBox Team,
>
> I hope this email finds you well. I am writing to report an issue I encountered while using PDFBox version 3.0.0. It appears that there is a problem when attempting to extract pages from one PDF and add them to another PDF.
> While using the same code and PDFBox version 2.0.29, it is perfectly working and output PDF contains no blank pages.



AW: Issue with PDFBox 3.0.0 - Unable to Extract and Add Pages

Posted by Fabian Zünd SI-Solutions Gmbh <zu...@si-solutions.ch>.
Hello Amber Prakash Verma

Last week i reported on this issue as well, and it was confirmed by Tilman Hausherr as a bug.

See https://issues.apache.org/jira/browse/PDFBOX-5775

Mit freundlichen Grüssen
 
Fabian Zünd
ICT Techniker EFZ  / Modul Programmierer
 
 

 
 
Industriestrasse 19
CH-9450 Altstätten SG
 
+41 71 595 10 60
+41 77 261 16 21
 
 
www.si-solutions.ch
zuend@si-solutions.ch
 


-----Ursprüngliche Nachricht-----
Von: Amber Prakash Verma <am...@newgensoft.com.INVALID> 
Gesendet: Dienstag, 27. Februar 2024 08:56
An: users@pdfbox.apache.org
Cc: Komal <ko...@newgensoft.com>; Prasad Nemmikanti <pr...@newgensoft.com>
Betreff: Issue with PDFBox 3.0.0 - Unable to Extract and Add Pages

Dear PDFBox Team,

I hope this email finds you well. I am writing to report an issue I encountered while using PDFBox version 3.0.0. It appears that there is a problem when attempting to extract pages from one PDF and add them to another PDF.
While using the same code and PDFBox version 2.0.29, it is perfectly working and output PDF contains no blank pages.

Issue Description:

  *
Version: PDFBox 3.0.0
  *
Problem: When using the PDFBox library to extract pages from one PDF file and add them to another PDF or a new PDF file, the resulting document contains blank pages.


Steps to Reproduce:

  *
Load an existing PDF document.
  *
Extract pages from document.
  *
Add the extracted Pages to a new PDF.
  *
Save the modified PDF.

Expected Result:
The resulting PDF should contain the extracted pages without any blank content.

Actual Result:
The resulting PDF contains blank pages.

Additional Information:

  *
I have attached the code snippet that reproduces the issue
  *
I am using the following dependencies.
PDFBox version 3.0.0
Java Version - 1.8.0_91


Code Snippet:
​```
       try{
          for (int i = 1; i < iDestPageNumber; i++)
          {
             PDPage page = destReader.getPage(i-1);
             page.setMediaBox(destReader.getPage(i-1).getMediaBox());
             page.setResources(destReader.getPage(i-1).getResources());
             tempDocument.addPage(page);
             iOutputPageCount++;
          }

          int srcPages = srcReader.getNumberOfPages();
          for (int i = 0; i < srcPages; i++)
          {                                         
             PDPage page = srcReader.getPage(i);
             page.setMediaBox(srcReader.getPage(i).getMediaBox());
             page.setResources(srcReader.getPage(i).getResources());
             tempDocument.addPage(page);
             iOutputPageCount++;
          }

          for (int i =iDestPageNumber; i <= destPages; i++)
          {
             PDPage page = destReader.getPage(i-1);
             page.setMediaBox(destReader.getPage(i-1).getMediaBox());
             page.setResources(destReader.getPage(i-1).getResources());
             tempDocument.addPage(page);
             iOutputPageCount++;
         }
           tempDocument.save(outputPath);
             tempDocument.close();
}
```

I would appreciate any guidance, suggestions, or potential solutions to resolve this issue. If this is a known problem, please let me know if there are any workarounds or if a fix is planned in a future release.

Thank you for your time and assistance. I appreciate the hard work you put into maintaining the PDFBox library.

Best regards,

Amber Prakash Verma
amber.vema@newgensoft.com
Newgen Software





Disclaimer: This e-mail and any attachment may contain confidential, proprietary or legally privileged information. If you are not the original intended recipient and have erroneously received this message, you are prohibited from using, copying, altering or disclosing the content of this message. Please delete it immediately and notify the sender. Newgen Software Technologies Ltd (NSTL) accepts no responsibilities for loss or damage arising from the use of the information transmitted by this email including damages from virus and further acknowledges that no binding nature of the message shall be implied or assumed unless the sender does so expressly with due authority of NSTL.