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

Michael Klink commented on PDFBOX-5696:
---------------------------------------

{quote}because the appearance stream is now a dictionary{quote}

Not only has that appearance stream lost its stream data, it also has been 
added to an object stream which is not possible for streams. This might even 
have caused the loss of the stream data.

Furthermore, another issue becomes apparent already in the first saved object: 
This single revision document has a cross reference stream with segmented 
object number ranges:
{noformat}/Index [0 3 4 1 8 13 22 3 26 9
36 15 52 5]
{noformat}
But single revision documents must have a single subsection cross reference 
only starting with object number 0 having _Size_ entries. Also there must be a 
mapping for every object number from 0 to _Size - 1 which isn't the case here 
either.
Usually PDF viewers have no problems if these rules aren't followed but in some 
cases (e.g. signature validation) that might result in issues.

> COSStream lost, becomes a COSDictionary
> ---------------------------------------
>
>                 Key: PDFBOX-5696
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5696
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 3.0.0 PDFBox
>            Reporter: Tilman Hausherr
>            Priority: Critical
>         Attachments: 30-1.pdf, 30-2.pdf, CambriaMath.ttf, TemplateTank.pdf
>
>
> This is reduced from the example presented by Pados Attila on the mailing list
> {code}
> public static void main(String[] args) throws IOException
> {
>     InputStream resourceAsStream = 
> NewClass.class.getResourceAsStream("/pdf/TemplateTank.pdf");
>     try (PDDocument a1doc = Loader.loadPDF(new 
> RandomAccessReadBuffer(resourceAsStream)))
>     {
>         PDAcroForm form = a1doc.getDocumentCatalog().getAcroForm();
>         PDResources dr = form.getDefaultResources();
>         form.getField("Site Name").setValue("Site Name");
>         a1doc.save(new File("30-1.pdf"));
>         PDFont font = PDType0Font.load(a1doc, 
> PdfGenerator.class.getResourceAsStream("/fonts/CambriaMath.ttf"), false);
>         dr.add(font);
>         a1doc.save(new File("30-2.pdf"));
>     }
> }
> {code}
> The result file 30-1.pdf has "Site Name" in the rendering, the result file 
> 30-2.pdf doesn't, because the appearance stream is now a dictionary.
> (The test was done on jdk21, I didn't test on another jdk)



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

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

Reply via email to