[
https://issues.apache.org/jira/browse/PDFBOX-1504?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andreas Lehmkühler resolved PDFBOX-1504.
----------------------------------------
Resolution: Fixed
Fix Version/s: 1.8.0
Assignee: Andreas Lehmkühler
This issue was fixed after solving PDFBOX-1517
Thanks for the contribution!
> Split document issue
> --------------------
>
> Key: PDFBOX-1504
> URL: https://issues.apache.org/jira/browse/PDFBOX-1504
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 1.7.1
> Reporter: Duarte Alexandre
> Assignee: Andreas Lehmkühler
> Fix For: 1.8.0
>
>
> I've seen a bug trying to split pages of a pdf document.
> For example, I got a 5 pages pdf document and I try to create a document with
> pages 4 to 5.
> I set startPage to 3 and endPage to 5 (also tried to set page number to 3)
> but it creates a document with pages 3 to 4 and a other one with page 5.
> I analysed a little bit the problem and it looks like it comes from the value
> of pageNumber variable in Splitter.class.
> This is how I solved it (rewriting 3 methods) :
> @Override
> protected void processPages(List pages) throws IOException {
> Iterator iter = pages.iterator();
> while( iter.hasNext() ) {
> PDPage page = (PDPage)iter.next();
> pageNumber++;
> if (pageNumber >= getStartPage() && pageNumber <= getEndPage())
> {
> processNextPage( page );
> }
> else {
> if (pageNumber > getEndPage()) {
> break;
> }
> }
> }
> }
>
> @Override
> protected void processNextPage( PDPage page ) throws IOException {
> createNewDocumentIfNecessary();
> PDPage imported = currentDocument.importPage( page );
> imported.setCropBox( page.findCropBox() );
> imported.setMediaBox( page.findMediaBox() );
> // only the resources of the page will be copied
> imported.setResources( page.getResources() );
> imported.setRotation( page.findRotation() );
> }
>
> @Override
> protected boolean isNewDocNecessary() {
> return (pageNumber % getSplitAtPage() == 0 && pageNumber !=
> getEndPage()) || currentDocument == null;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira