function newpage($closepage = true) { global $pdfdoc, $orientation, $current_page; $result = 0; $rm = 0; if ($closepage) { PDF_end_page($pdfdoc); /* Output the current part of the in-memory created PDF document */ print PDF_get_buffer($pdfdoc); } switch ($orientation) { case LANDSCAPE: /* Create a DIN A4 landscape page */ PDF_begin_page($pdfdoc, 842, 595); $result = 565; $rm = 812; break; case PORTRAIT: /* Create a DIN A4 landscape page */ PDF_begin_page($pdfdoc, 595, 842); $result = 812; $rm = 565; break; } if ($current_page != 1) { // Make an instance of the class $text = new jh_pdf_flowingtext(&$pdfdoc, &$result, 30, $rm, 30); $text->setfontsize(9); $text->addtext("Página {$current_page}", true); $text->puttext(30, $result, "right", 0); $result -= 26; } $current_page++; return $result; }
function newpage($closepage = true) { 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; }
<?php $p = PDF_new(); PDF_open_file($p); PDF_begin_page($p, 595, 842); $im = pdf_open_jpeg($p, "php-big.jpg"); pdf_place_image($p, $im, 200, 700, 1.0); PDF_save($p); // Save current coordinate system settings $nx = 50 / PDF_get_value($p, "imagewidth", $im); $ny = 100 / PDF_get_value($p, "imageheight", $im); PDF_scale($p, $nx, $ny); pdf_place_image($p, $im, 200 / $nx, 600 / $ny, 1.0); PDF_restore($p); // Restore previous pdf_close_image($p, $im); PDF_end_page($p); PDF_close($p); $buf = PDF_get_buffer($p); $len = strlen($buf); Header("Content-type:application/pdf"); Header("Content-Length:{$len}"); Header("Content-Disposition:inline; filename=coords.pdf"); echo $buf; PDF_delete($p);
<?php session_start(); //create handle for new PDF document $pdf = PDF_new(); //open a file pdf_open_file PDF_open_file($pdf, ""); //start a new page PDF_begin_page($pdf, 595, 842); //get and use a font object $font = PDF_findfont($pdf, "Times-Roman", "host", 0); PDF_setfont($pdf, $font, 12); /*print text*/ // PULLING OF DATA AND OTHER PRINTING INFORMATION------------------------ if ($_SESSION['role'] == 'admin' || $_COOKIE['role'] == 'admin') { include 'dbFunctions.php'; $expenditure_id = $_GET['expenditure_id']; $query = "SELECT * FROM expenditure WHERE expenditure_id = {$expenditure_id}"; $runquery = mysqli_query($connect, $query); while ($runrows = mysqli_fetch_array($runquery)) { $debit_card = $runrows['debit_card']; $amex_card = $runrows['amex_card']; $visa_card = $runrows['visa_card']; $total_staff_salary = $runrows['total_staff_salary']; $phone_bill = $runrows['phone_bill']; $rent_bill = $runrows['rent_bill']; $electricity_bill = $runrows['electricity_bill']; $director_fee = $runrows['director_fee']; $date = $runrows['date']; $desc = $runrows['desc']; $total_amount = $runrows['total_amount'];
*/ $RADIUS = 200.0; $MARGIN = 20.0; $p = PDF_new(); /* create a new PDFlib object */ /* open new PDF file; insert a file name to create the PDF on disk */ if (PDF_open_file($p, "") == 0) { die("Error: " . PDF_get_errmsg($p)); } /* This line is required to avoid problems on Japanese systems */ PDF_set_parameter($p, "hypertextencoding", "winansi"); PDF_set_info($p, "Creator", "pdfclock.php"); PDF_set_info($p, "Author", "Rainer Schaaf"); PDF_set_info($p, "Title", "PDF clock (PHP)"); /* start a new page */ PDF_begin_page($p, 2 * ($RADIUS + $MARGIN), 2 * ($RADIUS + $MARGIN)); PDF_translate($p, $RADIUS + $MARGIN, $RADIUS + $MARGIN); PDF_setcolor($p, "fillstroke", "rgb", 0.0, 0.0, 1.0, 0.0); PDF_save($p); /* minute strokes */ PDF_setlinewidth($p, 2.0); for ($alpha = 0; $alpha < 360; $alpha += 6) { PDF_rotate($p, 6.0); PDF_moveto($p, $RADIUS, 0.0); PDF_lineto($p, $RADIUS - $MARGIN / 3, 0.0); PDF_stroke($p); } PDF_restore($p); PDF_save($p); /* 5 minute strokes */ PDF_setlinewidth($p, 3.0);
PDF_set_parameter($p, "SearchPath", $searchpath); /* open new PDF file; insert a file name to create the PDF on disk */ if (PDF_open_file($p, "") == 0) { die("Error: " . PDF_get_errmsg($p)); } /* This line is required to avoid problems on Japanese systems */ PDF_set_parameter($p, "hypertextencoding", "winansi"); PDF_set_info($p, "Creator", "image.php"); PDF_set_info($p, "Author", "Rainer Schaaf"); PDF_set_info($p, "Title", "image sample (PHP)"); $imagefile = "nesrin.jpg"; $image = PDF_load_image($p, "auto", $imagefile, ""); if (!$image) { die("Error: " . PDF_get_errmsg($p)); } /* dummy page size, will be adjusted by PDF_fit_image() */ PDF_begin_page($p, 10, 10); PDF_fit_image($p, $image, 0, 0, "adjustpage"); PDF_close_image($p, $image); PDF_end_page($p); /* close page */ PDF_close($p); /* close PDF document */ $buf = PDF_get_buffer($p); $len = strlen($buf); header("Content-type: application/pdf"); header("Content-Length: {$len}"); header("Content-Disposition: inline; filename=image.pdf"); print $buf; PDF_delete($p); /* delete the PDFlib object */
} PDF_set_parameter($p, "SearchPath", $searchpath); /* This line is required to avoid problems on Japanese systems */ PDF_set_parameter($p, "hypertextencoding", "winansi"); PDF_set_info($p, "Creator", "businesscard.php"); PDF_set_info($p, "Author", "Thomas Merz"); PDF_set_info($p, "Title", "PDFlib block processing sample (PHP)"); $blockcontainer = PDF_open_pdi($p, $infile, "", 0); if ($blockcontainer == 0) { die("Error: " . PDF_get_errmsg($p)); } $page = PDF_open_pdi_page($p, $blockcontainer, 1, ""); if ($page == 0) { die("Error: " . PDF_get_errmsg($p)); } PDF_begin_page($p, 20, 20); /* dummy page size */ /* This will adjust the page size to the block container's size. */ PDF_fit_pdi_page($p, $page, 0, 0, "adjustpage"); /* Fill all text blocks with dynamic data */ foreach ($data as $key => $value) { if (PDF_fill_textblock($p, $page, $key, $value, "embedding encoding=winansi") == 0) { printf("Warning: %s\n ", PDF_get_errmsg($p)); } } PDF_end_page($p); /* close page */ PDF_close_pdi_page($p, $page); PDF_close($p); /* close PDF document */ PDF_close_pdi($p, $blockcontainer);
PDF_set_parameter($p, "SearchPath", $searchpath); /* This line is required to avoid problems on Japanese systems */ PDF_set_parameter($p, "hypertextencoding", "winansi"); PDF_set_info($p, "Creator", "quickreference.php"); PDF_set_info($p, "Author", "Thomas Merz"); PDF_set_info($p, "Title", "mini imposition demo (php)"); $manual = PDF_open_pdi($p, $infile, "", 0); if (!$manual) { die("Error: " . PDF_get_errmsg($p)); } $row = 0; $col = 0; PDF_set_parameter($p, "topdown", "true"); for ($pageno = $startpage; $pageno <= $endpage; $pageno++) { if ($row == 0 && $col == 0) { PDF_begin_page($p, $width, $height); $font = PDF_load_font($p, "Helvetica-Bold", "winansi", ""); PDF_setfont($p, $font, 18); PDF_set_text_pos($p, 24, 24); PDF_show($p, "PDFlib Quick Reference"); } $page = PDF_open_pdi_page($p, $manual, $pageno, ""); if (!$page) { die("Error: " . PDF_get_errmsg($p)); } $optlist = sprintf("scale %f", 1 / $maxrow); PDF_fit_pdi_page($p, $page, $width / $maxcol * $col, ($row + 1) * $height / $maxrow, $optlist); PDF_close_pdi_page($p, $page); $col++; if ($col == $maxcol) { $col = 0;
function OpenPage() { if ($this->numeroPagina > -1) { // Construção de página normal $this->ClosePage(); $this->numeroPagina++; PDF_begin_page($this->pdf, $this->largura, $this->altura); $this->pagOpened = TRUE; } else { $this->numeroPagina++; if ($this->renderCapa) { $this->MakeCapa(); } } }