dealfonso / sapp

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

"PDFDoc->to_pdf_file_s" with rebuild parameter to "true" cannot be signed by multiple certificates #22

Closed raimon-segura closed 1 year ago

raimon-segura commented 1 year ago

Hi!,

I've noticed that if I set "$rebuild" to true in PDFDoc::to_pdf_file_s($rebuild = false) the pdf cannot be signed by multiple certificates, I've followed " _generate_signature_in_document()" doc...

With "$rebuild = false" all works well, so I'm not sure if I have to set to true, or false, ...or maybe true only in the last call...

which is better?

thanks!

dealfonso commented 1 year ago

Hi,

rebuilding a PDF document means removing any element in the document and adding it again. This is useful to optimize documents, but this also means that the document is modified, so the properties of the signature are lost.

So, do not use $rebuild = true unless the document is not signed.

Regards

raimon-segura commented 1 year ago

Thanks!..

so, as a resume its ok to rebuild the first time, right?

I've tested and it works well, rebuilding only the first time... it saves 1kb haha, from 441,4Kb to 440,6Kb.. But I'm thinking to not rebuild.

Many thanks!