dealfonso / sapp

Simple and Agnostic PDF Document Parser in PHP - sign PDF docs using PHP
GNU Lesser General Public License v3.0
121 stars 32 forks source link

Can it save changes incrementally? #43

Closed kmgbarroga closed 1 year ago

kmgbarroga commented 1 year ago

Good day, I am reaching out to ask if it is possible to add images to pdf and save the changes incrementally. Is that possible with this library? Your response will be highly appreciated. Thank you!

dealfonso commented 1 year ago

hi, not at this moment. I have a class PDFDocWithContents in which there is a function called add_image, but it still needs work. Sorry.

parallels999 commented 1 year ago

@kmgbarroga did you try setasign/fpdi?

kmgbarroga commented 1 year ago

Is it opensource? I haven't checked it yet

@kmgbarroga did you try setasign/fpdi?

dealfonso commented 1 year ago

@kmgbarroga did you try setasign/fpdi?

does FPDI manage incremental docs?

kmgbarroga commented 1 year ago

@kmgbarroga did you try setasign/fpdi?

does FPDI manage incremental docs?

From what I have seen so far, they don't. Just $pdf->Output();, that's all there is.

parallels999 commented 1 year ago

You can import pages, and add changes incrementally

kmgbarroga commented 1 year ago

I stand corrected, I don't know if they do incremental changes. The closest thing I've seen is pymupdf, but I'm looking for a php lib not python.

You can import pages, and add changes incrementally I get what you mean, but there is another meaning of "incremental" in pdf, it means that I could roll back to the previously committed change. Correct me if I am wrong.

parallels999 commented 1 year ago

but there is another meaning of "incremental" in pdf, it means that I could roll back to the previously committed change.

Ok, no idea about that

dealfonso commented 1 year ago

An incremental PDF document is a differential document. The final PDF file contains the original version along with changes; then, if more changes are made, you can add another block of differences. That is how signature works: there is a document, and you add an incremental document that only contains the signature; then it is possible to check whether the document has been changed or not using a hash for the first part.

Using this mechanism, it is possible to keep track of any changes and revert to prior versions.

It is possible to read the PDF document with any text reader and you'll notice multiple %%EOF blocks if the document is incremental.