diff --git a/api.php b/api.php index 5811d6b..2f8c4b5 100644 --- a/api.php +++ b/api.php @@ -1073,6 +1073,22 @@ switch($request[0]) { } break; + /* APIDOC: project/signatureform + description(generate and download the signature page PDF for the currently logged in user/project, as a BASE64 ENCODED string) + return(pdf base64 encoded string) + */ + case 'signatureform': + ob_start(); + //this tells it to simply return the [S]tring instead of outputting headers to force pdf display in a browser + $PDFDEST="S"; + include "register_participants_signature.php"; + $c=ob_get_contents(); + ob_end_clean(); + $b64=base64_encode($c); + $ret['status']="ok"; + $ret['pdf']=$b64; + break; + default: $ret['status']="error"; $ret['error']="invalid project API command ({$request[1]})"; diff --git a/register_participants_main.php b/register_participants_main.php index 41c23a2..9ab58ce 100644 --- a/register_participants_main.php +++ b/register_participants_main.php @@ -191,10 +191,10 @@ echo ""; //FIXME: this should be a global detection so we can use the results elsewhere, especially for all the reports! - if(function_exists("pdf_new")) + if(file_exists("tcpdf/tcpdf.php")) $sigfile="register_participants_signature.php"; - else if(file_exists("tcpdf/tcpdf.php")) - $sigfile="register_participants_signature_tcpdf.php"; + else if(function_exists("pdf_new")) + $sigfile="register_participants_signature_pdflib.php"; else $sigfile=""; diff --git a/register_participants_signature.php b/register_participants_signature.php index 1e9d3a3..5a1b614 100644 --- a/register_participants_signature.php +++ b/register_participants_signature.php @@ -64,8 +64,6 @@ } //END OF AUTH, now lets try to generate a PDF using only PHP :) this should be fun! - - $pdf=new pdf( "Participant Signature Page ($registration_number)" ); $pdf->setFontSize(11); @@ -215,5 +213,8 @@ function sig($pdf, $text) $pdf->WriteHTML("

"); } - echo $pdf->output(); + if(isset($PDFDEST)) + echo $pdf->output('',$PDFDEST); + else + echo $pdf->output(); ?> diff --git a/tcpdf.inc.php b/tcpdf.inc.php index 238e7e6..aae3d24 100644 --- a/tcpdf.inc.php +++ b/tcpdf.inc.php @@ -538,8 +538,7 @@ class pdf extends TCPDF { $filename=strtolower($this->subject); $filename=ereg_replace("[^a-z0-9]","_",$filename).'.pdf'; } - parent::Output($filename, $dest); + return parent::Output($filename, $dest); } - }
"; echo "