I added that :

Get the COSObject of the new annotation (stamp), add it to the set of
COSToWrite and pass this information to the saveIncremental.

Set<COSDictionary> setCOSObjectToWrite =  new HashSet<COSDictionary>() ;
setCOSObjectToWrite.add(stamp.getCOSObject());

doc.saveIncremental(resultFile, setCOSObjectToWrite);

And then it works.

But it sounds like a bug in PDF2...







Le mar. 31 oct. 2023 à 08:32, Tilman Hausherr <thaush...@t-online.de> a
écrit :

> Hi,
> I don't have time right now to test my theory, which would require
> setting update marks on the intermediate pagetree objects.
> In the meantime please try using the other saveIncremental call, where
> you pass COSDictionary objects. You'll probably need to only pass the
> page and your annotation and the appearance stuff, but not the catalog.
> (Unless you did other changes)
>
> I'll test my theory later, but this will likely only result in an
> improved javadoc.
>
> Tilman
>
> On 30.10.2023 21:16, Frédéric Ravetier wrote:
> > Thanks for your answer Tilman,
> >
> > * I was using 2.0.29
> > * this code is working well with all the pdf I used until now
> > * I did a test using pdfbox3 and it works but my code using pdf3 is not
> > production ready :(
> >
> > I prepare a test class that you can use
> >
> https://drive.google.com/file/d/1Nqkck4VZXZXjFxEY9XlvVNuF-SOrKH6S/view?usp=sharing
> > It uses another PDF that I shared with you :
> >
> https://drive.google.com/file/d/1G66GxpbxWuETGmO9DM6m8Y-EZlTw_I1h/view?usp=sharing
> >
> > You need to place both PDF into testfiles/input/
> >
> > testB is using a PDF where it works
> > testC is using the PDF I shared before where it does not work.
> >
> > Fred
> >
> > Le lun. 30 oct. 2023 à 19:12, Tilman Hausherr <thaush...@t-online.de> a
> > écrit :
> >
> >> Hi,
> >>
> >> The annotations are missing in the incremental part. My guess is that
> >> you didn't include it in the update. You've updated the document catalog
> >> but not the page. Read the javadoc of the saveIncremental() carefully.
> >> If you can't get it to work, please share the smallest possible code
> >> that reproduces the effect.
> >>
> >> The current 2 version is 2.0.29.
> >>
> >> However I'm also wondering whether you hit a bug, or rather a problem.
> >> The page tree has several levels so if you use the "classic" incremental
> >> save then there is no direct path from the catalog to the page.
> >>
> >> Tilman
> >>
> >> On 30.10.2023 13:57, Frédéric Ravetier wrote:
> >>> Hi,
> >>>
> >>> I am using the same code and PDFbox2 to add annotations on PDF.
> >>> The annotations are not displayed and I think they are not in the final
> >> PDF
> >>> when I am using one specific PDF.
> >>> This is the PDF :
> >>>
> >>
> https://drive.google.com/file/d/1iyPlWZkU9SgPjUCCCI5_A190xAz8b4-5/view?usp=sharing
> >>> This is the PDF where I added annotation and save using
> incrementalSave :
> >>>
> >>
> https://drive.google.com/file/d/1jlkknjPtbofGuTqj4urLWfXjZt9CjH0d/view?usp=sharing
> >>> Do you have any ideas ? Do you need more information ?
> >>>
> >>> Best regards,
> >>> Fred
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> >> For additional commands, e-mail: users-h...@pdfbox.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>
>

Reply via email to