Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
6.92k stars 660 forks source link

Incremental Document updates #816

Closed nihaopaul closed 3 years ago

nihaopaul commented 3 years ago

can PDF-LIB support incremental updates? i loaded a document that was signed with incremental updates and then saved it again and noticed all of the incremental updates

startxref n.. %%EOF

startxref n.. %%EOF

startxref n.. %%EOF

had been collapsed into one at the end, i was testing if pdf-lib could be used to build PAdes-LTV PDF's, the only part not found is the incremental updates but i've been amazed by this library so far. the only other way is that i manually append to the document but that gets messy on a double signature.

therpobinski commented 3 years ago

Hi, it is the same problem I have. Have you found a solution? I have a document in which I add a text before signing it. But adding the text with pdf-lib does not respect the incremental signature structure. Before adding the second stamp:

%PDF-1.7
  <<content>>
  <<
    /Type /Sig
    /Filter /Adobe.PPKLite
    /SubFilter /adbe.pkcs7.detached
    /ByteRange [ 0 xx xxxx xxx ]
    /Contents <xxxxxxxxxxxxxxx>
  startxref
  xxxx
%%EOF

After adding the text:

%PDF-1.7
  <<content>>
  <<
    /Type /Sig
    /Filter /Adobe.PPKLite
    /SubFilter /adbe.pkcs7.detached
    /ByteRange [ 0 xx xxxx xxx ]
    /Contents <xxxxxxxxxxxxxxx>

  <<who adds the text content using pdf-lib>>

  startxref
  xxxx
%%EOF

But, the correct thing would be:

%PDF-1.7
  <<content>>
  <<
    /Type /Sig
    /Filter /Adobe.PPKLite
    /SubFilter /adbe.pkcs7.detached
    /ByteRange [ 0 xx xxxx xxx ]
    /Contents <xxxxxxxxxxxxxxx>
  startxref
  xxxx
%%EOF

<<who adds the text content using pdf-lib>>

  startxref
  xxxx
%%EOF

Do you have any ideas to correct this problem or is there no solution in this library?

aashishvanand commented 3 years ago

Hi, Any updates on this ?

Hopding commented 3 years ago

Not yet, but it's on the roadmap: https://github.com/Hopding/pdf-lib/discussions/998.

aallvi commented 2 years ago

hi, i am trying to do the same thing that your , how you get a solution? i need tu put image in a pdf that already have a signature.

pdf-lib accept now the incremental saves and updates? you use another library? any help is appreciate.

Thanks

PatrikAarnivaara commented 2 years ago

can PDF-LIB support incremental updates? i loaded a document that was signed with incremental updates and then saved it again and noticed all of the incremental updates

startxref n.. %%EOF

startxref n.. %%EOF

startxref n.. %%EOF

had been collapsed into one at the end, i was testing if pdf-lib could be used to build PAdes-LTV PDF's, the only part not found is the incremental updates but i've been amazed by this library so far. the only other way is that i manually append to the document but that gets messy on a double signature.

Any luck finding a solution in javascript?

aallvi commented 2 years ago

Hi patrik, i dont found a solution in javascript, i have to change this part of my aplication to python, with a library called endesive, is easy to use, i recommended to you to use

PatrikAarnivaara commented 2 years ago

Thanks, I also tried pymupdf. Well hummusjs (not maintained any longer) does incremental updates, I tried it and it works.