Execute Custom php Code: Frequently Asked Questions

Arclab® Web Form Builder

question_answer Execute Custom PHP Code F.A.Q. Index

comment  How to use a dynamic Attachment File Name

 

The file name set in the dialog can be overwritten using the php variable $att_file_name.

Samples:

$att_file_name = "abc.pdf";
$att_file_name = "$ID23.pdf"

comment  How to access the PNG Image of a Signature Field

 

The base64 encoded png image is stored in the variable $IDxx_b64, e.g. $ID21_b64
(you can get the IDxx when you click on the signature field in the form).

Use:

// base 64 encoded image bytes
$IDxx_b64

// image as data url
$dataurl = 'data:image/png;base64,'.$IDxx_b64;

// image bytes (image data stream)
$bytes = base64_decode($IDxx_b64);

 

If you want to add the signature to a pdf file created using TCPDF use e.g.

// insert the image
$pdf->Image('@'.base64_decode($IDxx_b64),10,10);

// the '@' character is used to indicate that the 1st parameter contains an image data stream and not an image file name
// 10,10 is x and y
// for further details and parametes look at the TCPDF:Image user manual

// if the signature is optional (NOT a required field) use:
if($IDxx_b64) $pdf->Image('@'.base64_decode($IDxx_b64),10,10);

 

If you want to add the signature to a pdf file created using FPDF use e.g.

$dataurl = 'data:image/png;base64,'.$IDxx_b64;
$pdf->Image($dataurl,10,10,0,0,'PNG');

// 10,10 is x and y
// 0,0 for auto size
// specify the image type PNG

// if the signature is optional (NOT a required field) use:
if($IDxx_b64)
{
$dataurl = 'data:image/png;base64,'.$IDxx_b64;
$pdf->Image($dataurl,10,10,0,0,'PNG');
}

comment  Sample: Add PNG Image of Signature Field to PDF using TCPDF

 

The base64 encoded png image is stored in the variable $IDxx_b64, e.g. $ID21_b64
(you can get the IDxx when you click on the signature field in the form).

 

TCPDF Image Sample:

...
$html = '<p>...</p>';

// add HTML content
$pdf->writeHTMLCell(0, 0, 10, 10, $html);


// insert image
$pdf->Image('@'.base64_decode($IDxx_b64),10,10);

// 10,10 is x and y (by default in mm) from the upper left corner
// for further details and parametes look at the TCPDF:Image user manual

// add the image function before outputting the PDF !
$att_content_data = $pdf->Output('ignored', 'S');

comment  Sample: Add PNG Image of Signature Field to PDF using FPDF

 

The base64 encoded png image is stored in the variable $IDxx_b64, e.g. $ID21_b64
(you can get the IDxx when you click on the signature field in the form).

 

FPDF Image Sample:

...
// add some text
$pdf->Cell(0,10,'Hello World');


$dataurl = 'data:image/png;base64,'.$IDxx_b64;
$pdf->Image($dataurl,10,10,0,0,'PNG');

// 10,10 is x and y from the upper left corner
// use 0,0 for auto size (width and height)

// add the image function before outputting the PDF !
$att_content_data = $pdf->Output('S');

Please contact us if you cannot find an answer to your question in the F.A.Q. or user manual.

Contact Arclab Support