示例#1
0
 function run()
 {
     global $output_format;
     global $form_action;
     global $sbsearch_x;
     global $pdfdoc;
     global $orientation;
     if (isset($output_format)) {
         $this->outputformat = $output_format;
     }
     if (isset($form_action) || !$this->filtered) {
         reset($this->bands);
         if ($this->outputformat == PDF) {
             if (!$this->issubreport) {
                 header("Content-type: application/pdf");
                 /* Create a PDFlib object */
                 $this->pdf = PDF_new();
                 $pdfdoc = $this->pdf;
                 $orientation = $this->orientation;
                 /* Create a PDF document in memory */
                 PDF_open_file($this->pdf, "");
                 /* Create the first page */
                 $this->ypos = newpage(false);
                 $this->pageheader();
             }
             /* Make an instance of the table class */
             switch ($this->orientation) {
                 case LANDSCAPE:
                     $this->table = new jh_pdf_table(&$this->pdf, &$this->ypos, $this->subx, 812, 30);
                     break;
                 case PORTRAIT:
                     $this->table = new jh_pdf_table(&$this->pdf, &$this->ypos, $this->subx, 565, 30);
                     break;
             }
             /* Set a function that will be called if a new page is necessary */
             $this->table->setnewpagefunction(newpage);
             if ($this->issubreport) {
                 $this->table->setverttableborderwidth(1);
                 $this->table->setverttablebordercolor(0);
                 //$this->table->setcolspacingwidth(1);
                 //$this->table->setcolspacingcolor(0);
                 $this->table->setrowspacingwidth(1);
                 $this->table->setrowspacingcolor(0);
             }
             $this->table->setheaderbgcolor($this->headercolor);
             $this->table->setbgcolors(array(false, 0.9));
         }
         if ($this->outputformat == HTML) {
             echo "<link rel=\"StyleSheet\" href=\"phpreport/report.css\" type=\"text/css\" />\n";
             echo "<style type=\"text/css\">";
             echo "@import url(\"phpreport/report.css\"); ";
             echo "</style>";
         }
         $w = "width=\"100%\"";
         if ($this->issubreport) {
             $w = "width=\"100%\"";
         }
         $b = "1";
         if ($this->issubreport) {
             $b = "0";
         }
         if ($this->outputformat == HTML) {
             if ($this->title != '') {
                 $fecha = date("d/m/Y h:m:s");
                 echo "<table {$w} border=\"0\"><tr><td><h2>{$this->title}</h2></td><td align=\"right\">{$fecha}</td></tr></table>";
             }
             echo "<table {$w} border=\"{$b}\" cellspacing=\"0\" cellpadding=\"2\">";
         }
         while (list($bandname, $bandparams) = each($this->bands)) {
             $this->renderBand($bandparams);
         }
         if ($this->outputformat == HTML) {
             if ($this->showsummaries) {
                 $cs = count($this->phpgrid->printable);
                 echo "<tr class=\"reportdetaileven\">";
                 echo "<td colspan=\"{$cs}\" align=\"right\">{$this->recordcount} registro(s)</td>";
                 echo "</tr>";
             }
             echo "</table>";
         }
         if ($this->outputformat == PDF) {
             /* Close the table (important!) */
             $this->table->endtable();
         }
         if ($this->showsummaries) {
             if ($this->outputformat == PDF) {
                 $rm = 0;
                 // Make an instance of the table class
                 switch ($this->orientation) {
                     case LANDSCAPE:
                         $rm = 812;
                         break;
                     case PORTRAIT:
                         $rm = 565;
                         break;
                 }
                 $this->ypos -= 10;
                 // Make an instance of the class
                 $text = new jh_pdf_flowingtext(&$this->pdf, &$this->ypos, 30, $rm, 30);
                 $text->setfontsize(9);
                 $text->addtext($this->recordcount . " registro(s)", true);
                 $text->puttext(30, $this->ypos, "right", 0);
                 $this->ypos -= 26;
             }
         }
         if ($this->outputformat == PDF) {
             if (!$this->issubreport) {
                 /* Close the last page */
                 PDF_end_page($this->pdf);
                 /* Close the PDF document */
                 PDF_close($this->pdf);
                 /* Output the current part of the in-memory created PDF document */
                 print PDF_get_buffer($this->pdf);
                 /* Delete the PDFlib object */
                 PDF_delete($this->pdf);
             }
         }
     } else {
         $sbsearch_x = 1;
         $this->phpgrid->showformatcombo = TRUE;
         $this->phpgrid->showgrid = 0;
         $this->phpgrid->run();
     }
 }
    global $pdf;
    if ($closepage) {
        PDF_end_page($pdf);
        /* Output the current part of the in-memory created PDF document */
        print PDF_get_buffer($pdf);
    }
    /* Create a DIN A4 page */
    PDF_begin_page($pdf, 595, 842);
    return 812;
}
/* Create the first page */
$ypos = newpage(false);
/* Split the example text into its lines */
$examplelines = split("\n", $exampletext);
/* Make an instance of the class */
$text = new jh_pdf_flowingtext(&$pdf, &$ypos, 30, 565, 30);
/* Set a function that will be called if a new page is necessary */
$text->setnewpagefunction(newpage);
/* Set the font size */
$text->setfontsize(26);
/* Loop through the lines of the example text */
foreach ($examplelines as $line) {
    if ($line != "") {
        /* If a line is non-empty, just feed it to the
           jh_pdf_flowingtext class */
        $text->addtext($line, true);
    } else {
        /* If a line is empty, interpret it as end-of-paragraph:
           output the text and leave some empty space */
        $text->putflowingtext();
        $ypos -= 26;