- Add another arg to newPage to allow overriding the page number. Want to

create a single pdf with multiple forms for students, each form should start
  on page 1.
- Add a prevLine() function to go back a line.
- Switch the output mechanism to output to an array (and then print that
  array).  For remote transport to downstream SFIABs, we dont' want to output
  the PDF, we want to bundle up the data and return it via. json.  we do NOT
  want downstream fairs communicating directly with our PDF generator, nor do we
  want users of downstream fairs authenticating themselves, from their home browser, as 
  a fair.  The user talks to their SFIAB, that SFIAB goes through the
  remote.php authentication mechanism, and a PDF gets returned.
This commit is contained in:
dave 2009-09-25 19:13:29 +00:00
parent 49c2e06cb8
commit 3a921ba3bf

View File

@ -115,7 +115,7 @@ class lpdf
pdf_stroke($this->pdf);
}
function newPage($width="",$height="")
function newPage($width="",$height="",$pagenumber=0)
{
if($width && $height)
{
@ -126,7 +126,7 @@ class lpdf
if($this->pagenumber>0)
pdf_end_page($this->pdf);
$this->pagenumber++;
$this->pagenumber = ($pagenumber == 0) ? ($this->pagenumber + 1) : $pagenumber;
//Letter size (8.5 x 11) is 612,792
pdf_begin_page($this->pdf,$this->loc($this->page_width),$this->loc($this->page_height));
@ -532,6 +532,15 @@ class lpdf
}
function prevLine()
{
$fontsize=pdf_get_value($this->pdf,"fontsize",0);
$lineheight=ceil($fontsize*1.2);
$this->yloc+=$this->currentFontSize*1.4/72;
}
function hr()
{
$fontsize=pdf_get_value($this->pdf,"fontsize",0);
@ -826,8 +835,10 @@ class lpdf
}
function output()
function outputArray()
{
$ret = array();
pdf_end_page($this->pdf);
//only close the image if it was opened to begin with
@ -835,18 +846,27 @@ class lpdf
pdf_close_image($this->pdf,$this->logoimage);
pdf_close($this->pdf);
$pdfdata=pdf_get_buffer($this->pdf);
$ret['data'] = pdf_get_buffer($this->pdf);
$filename=strtolower($this->page_subheader);
$filename=ereg_replace("[^a-z0-9]","_",$filename);
header("Content-type: application/pdf");
header("Content-disposition: inline; filename=sfiab_".$filename.".pdf");
header("Content-length: ".strlen($pdfdata));
header("Pragma: public");
echo $pdfdata;
$ret['header'][] = "Content-type: application/pdf";
$ret['header'][] = "Content-disposition: inline; filename=sfiab_".$filename.".pdf";
$ret['header'][] = "Content-length: ".strlen($ret['data']);
$ret['header'][] = "Pragma: public";
return $ret;
}
function output()
{
$data = $this->outputArray();
foreach($data['header'] as $h) header($h);
echo $data['data'];
}
function lpdf($header,$subheader,$logo)
{
$this->pdf=pdf_new();