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

Error opening a pdf in sapp - PDFDoc.php:755: generating xref using classic xref...trailer #16

Closed MoisesAlvesSousa closed 2 years ago

MoisesAlvesSousa commented 2 years ago

testdoc-signed.pdf

PS C:\wamp64\www\PROJETOSITE\2022\assinaturaDigital\assinaturaSAPP> php pdfsigni.php examples/testdoc.pdf "https://www.google.es/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" JOSIVAN.pfx > testdoc-signed.pdf Password: 'stty' não é reconhecido como um comando interno ou externo, um programa operável ou um arquivo em lotes. 805493 'stty' não é reconhecido como um comando interno ou externo, um programa operável ou um arquivo em lotes.

Debug info at C:\wamp64\www\PROJETOSITE\2022\assinaturaDigital\assinaturaSAPP\src\PDFDoc.php:755: generating xref using classic xref...trailer

dealfonso commented 2 years ago

Hi,

there are several problems in your test, but they all have the same root: you are using Windows.

The examples assume that you are using a Linux platform, and so they cannot be run in Windows as-is. Please create your own application and try again. My guess is that you are not very experienced in PHP or Linux, so my advice are:

  1. remove lines 35 and 37 from the example (system('stty -echo'); and system('stty +echo');). In that case, the password will appear on the screen as you are typing.
  2. and write the output to a file, instead of piping it using > in the command line. That implies changing line 84 (echo $docsigned;) to save such content to a file.
MoisesAlvesSousa commented 2 years ago

I'm new to PHP.

I'm creating an application to digitally sign PDF more than once.

This variable $docsigned, is there any method already created to save it in a PDF file?

MoisesAlvesSousa commented 2 years ago

I'm already developing my application with sapp. A doubt as I can insert the function set_metadata in my file. How can I call her.

MoisesAlvesSousa commented 2 years ago

I have a file with several pages in pdf, I wanted to put the graphic signature on each one as $obj->set_signature_appearance(0, [ $p_x, $p_y, $p_x + $i_w, $p_y + $i_h ], $image); I created a loop but it is only on the last page. Would you like to do that?

dealfonso commented 2 years ago

Hi,

from your last message, I see that you have managed to write the file (e.g. using file_put_contents).

On your last query... in a PDF file, one signature can only have one appearance. So, when you use set_signature_appearance at different times, the position is updated. In case you want multiple graphics, you can sign the document multiple times, but I find that it has no sense: signing the document is useful to keep the integrity of the document. So signing the document multiple times, would mean to keep the same integrity multiple times.

If you simply want to add multiple graphics to a document and then signing it, it is a different approach, but keep in mind that in that case you sign a different document than the original one.

MoisesAlvesSousa commented 2 years ago

Good Morning So I still can't put the method information in the signature.

public function set_metadata(){ $name $reason $location $contact } How could I enter this information?

And thank you so much for this magnificent project. Thank you so

dealfonso commented 2 years ago

At this moment, the metadata is not included in the final document.