Created
January 10, 2019 23:31
-
-
Save Ravenna/13e2bb28a2fd56c85c9c53edd0ad4622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$writer = new SetaPDF_Core_Writer_Http('output.pdf', true); | |
$document = SetaPDF_Core_Document::loadByFilename('test.pdf', $writer); | |
$formFiller = new SetaPDF_FormFiller($document); | |
$fields = $formFiller->getFields(); | |
$stamper = new SetaPDF_Stamper($document); | |
// Get Post Data | |
$name = $_POST["name"]; | |
$email = $_POST["email"]; | |
$signature = $_POST["base64"]; | |
$signature = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $signature)); | |
// Set fields | |
$fields['NAME']->setValue($name); // add some randomness | |
$fields['EMAIL']->setValue($email); | |
// Stamp Image | |
$image = SetaPDF_Core_Image::getByPath('signature.png'); | |
$imageStamp = new SetaPDF_Stamper_Stamp_Image($image); | |
$stamp = new SetaPDF_Stamper_Stamp_Image($image); | |
// Set Signature | |
$stamper->addStamp($stamp, array( | |
'position' => SetaPDF_Stamper::POSITION_LEFT_BOTTOM, | |
'translateX' => 0, | |
'translateY' => 10, | |
)); | |
$stamper->stamp(); | |
$document->save()->finish(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment