File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121$ settings = require 'settings.php ' ;
2222
2323$ fileToSign = __DIR__ . '/assets/Laboratory-Report.pdf ' ;
24- $ resultPath = 'signed.pdf ' ;
2524
2625// to create or update your access token you have to call generate-token.php first
2726if (!isset ($ _SESSION ['accessToken ' ]['access_token ' ])) {
7978 $ module ->setSigningAlgorithm ($ _POST ['algorithm ' ]);
8079
8180 // create a writer instance
82- $ writer = new SetaPDF_Core_Writer_File ( $ resultPath );
81+ $ writer = new SetaPDF_Core_Writer_String ( );
8382 $ tmpWriter = new SetaPDF_Core_Writer_TempFile ();
8483 // create the document instance
8584 $ document = SetaPDF_Core_Document::loadByFilename ($ fileToSign , $ tmpWriter );
139138
140139 $ document ->save ()->finish ();
141140
142- echo '<a href="data:application/pdf;base64, ' . base64_encode (file_get_contents ( $ resultPath )) . '" ' .
143- 'download=" ' . basename ( $ resultPath ) . ' ">download</a> | <a href="?">restart</a><br /> ' ;
141+ echo '<a href="data:application/pdf;base64, ' . base64_encode ($ writer -> getBuffer ( )) . '" ' .
142+ 'download="result.pdf ">download</a> | <a href="?">restart</a><br /> ' ;
144143
145144} catch (Throwable $ e ) {
146145 echo 'An error occurred: <pre> ' . $ e . '</pre> ' ;
Original file line number Diff line number Diff line change 2121$ settings = require 'settings.php ' ;
2222
2323$ fileToSign = __DIR__ . '/assets/Laboratory-Report.pdf ' ;
24- $ resultPath = 'signed.pdf ' ;
2524
2625// to create or update your access token you have to call generate-token.php first
2726if (!isset ($ _SESSION ['accessToken ' ]['access_token ' ])) {
7776 $ module ->setSigningAlgorithm ($ _POST ['algorithm ' ]);
7877
7978 // create a writer instance
80- $ writer = new SetaPDF_Core_Writer_File ( $ resultPath );
79+ $ writer = new SetaPDF_Core_Writer_String ( );
8180 // create the document instance
8281 $ document = SetaPDF_Core_Document::loadByFilename ($ fileToSign , $ writer );
8382
8685 $ signer ->setReason ('Testing Cumulo! ' );
8786 $ signer ->sign ($ module );
8887
89- echo '<a href="data:application/pdf;base64, ' . base64_encode (file_get_contents ( $ resultPath )) . '" ' .
90- 'download=" ' . basename ( $ resultPath ) . ' ">download</a> | <a href="?">restart</a><br /> ' ;
88+ echo '<a href="data:application/pdf;base64, ' . base64_encode ($ writer -> getBuffer ( )) . '" ' .
89+ 'download="result.pdf ">download</a> | <a href="?">restart</a><br /> ' ;
9190
9291} catch (Throwable $ e ) {
9392 echo 'An error occurred: <pre> ' . $ e . '</pre> ' ;
You can’t perform that action at this time.
0 commit comments