You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2026/10/09 06:42:00 UTC

[jira] [Comment Edited] (PDFBOX-6277) PDFMergerUtility writes /PageLabels without an entry for page index 0

    [ https://issues.apache.org/jira/browse/PDFBOX-6277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18125322#comment-18125322 ] 

Tilman Hausherr edited comment on PDFBOX-6277 at 10/9/26 6:41 AM:
------------------------------------------------------------------

I think I "get" it, the easiest solution should be to create a minimal valid page labels content if it is missing, instead of just the empty array.


was (Author: tilman):
I think I "get" it, the easiest solution should be to create a minimal valid page labels content if it is missing, instead of just the empty array. I don't have the time right now, but it will be done very soon.

> PDFMergerUtility writes /PageLabels without an entry for page index 0
> ---------------------------------------------------------------------
>
>                 Key: PDFBOX-6277
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-6277
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.37, 3.0.8 PDFBox
>            Reporter: Karol Bryd
>            Priority: Major
>             Fix For: 2.0.38, 3.0.9 PDFBox, 4.0.0
>
>         Attachments: PageLabelsMergeRepro.java, labels.pdf, nolabels.pdf, result.pdf
>
>
> Hello,
> I think I hit a bug in PDFBox related to merging documents with PDFMergerUtility.appendDocument and the way how it handles Page Labels. I verified that with the PDF spec and looks like it is a real problem, although I am not a PDF expert, so please verify.
> The problem can be reproduced by merging 2 files, when the first file has no /PageLabels and a later one has them PDFMergerUtility copies the labels shifted by the page count of the preceding documents, but never adds an entry for index 0, For example, when merging a 2 page unlabelled PDF with a 1-page PDF labelled /Nums [0 <</S /D>>] gives /PageLabels << /Nums [2 ...] >>
> I found in PDF spec documen, section 12.4.2 Table 28 this: *The tree shall include a value for page index 0"* and I actually stumbled upon this by processing documents merged with PDFBox with a tool based on PyMuPDF which raises an error: {color:#000000}IndexError: list index out of range{color}
> {color:#000000} {color}
> I tested other PDF libraries: aspose-pdf, pdfnet and pdfbox itself and they tolerate such files, but they report page labels differently and in an inconsistent way. Only PyMuPDF rejectes them.
>  
> Attached Java class reproduces the problem.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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