I don't know if there is any risk. Mostly that you forget to add enough objects. But if you do, you'll notice if you look at the file and don't see the changes.

Tilman

On 01.11.2023 10:34, Frédéric Ravetier wrote:
Thank you for this solution.

What is the risk to use the second incrementalSave with COS in param ?

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

    I got it to work with the classic method by adding this code
    before saving:


                COSDictionary parent =
    page.getCOSObject().getCOSDictionary(COSName.PARENT);
                while (parent != null)
                {
                    parent.setNeedToBeUpdated(true);
                    parent = parent.getCOSDictionary(COSName.PARENT);
                }

    In the screenshot below, the mouse is positioned on the page. The
    /Parent link goes back to the top of the page tree (object 436
    which is seen twice, but it's the same)


    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>  
<mailto: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



Reply via email to