function OpenFile() { $caminho = 'tmp/'; $lim_dir = opendir('tmp/'); $fonte = APP_ROOT . DS . 'arquivos/fontes/FreeMonoBold.ttf'; while ($lim_file = readdir($lim_dir)) { if ($lim_file != '.' && $lim_file != '..') { if (!substr_count($lim_file, date('Y-m-d'))) { @unlink('tmp/' . $lim_file); } } } $caminho .= date('Y-m-d') . '-'; list($usec, $sec) = explode(' ', microtime()); $caminho .= substr(md5($usec . $sec), 0, 8); $caminho .= '.pdf'; $this->caminho = APP_ROOT . DS . $caminho; $this->LinkArquivo = $caminho; $this->pdf = PDF_new(); pdf_set_parameter($this->pdf, 'FontOutline', 'monospaced=' . $fonte); PDF_open_file($this->pdf, $this->caminho); PDF_set_info($this->pdf, 'Creator', $this->owner); PDF_set_info($this->pdf, 'Author', $this->owner); PDF_set_info($this->pdf, 'Title', $this->titulo); if ($this->depurar) { echo '<b>PDF:</b> Objeto criado!<br>'; echo '<b>PDF:</b> O objeto foi criado no seguinte local -> ' . $this->LinkArquivo . '<br>'; } $this->OpenPage(); }
<?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'];
<?php /* $Id: pdfclock.php 14574 2005-10-29 16:27:43Z bonefish $ * A little PDFlib application to draw an analog clock. * */ $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);
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(); } }
<?php //getting new instance $pdfFile = new_pdf(); PDF_open_file($pdfFile, " "); //document info pdf_set_info($pdfFile, "Auther", "Ahmed Elbshry"); pdf_set_info($pdfFile, "Creator", "Ahmed Elbshry"); pdf_set_info($pdfFile, "Title", "PDFlib"); pdf_set_info($pdfFile, "Subject", "Using PDFlib"); //starting our page and define the width and highet of the document pdf_begin_page($pdfFile, 595, 842); //check if Arial font is found, or exit if ($font = PDF_findfont($pdfFile, "Arial", "winansi", 1)) { PDF_setfont($pdfFile, $font, 12); } else { echo "Font Not Found!"; PDF_end_page($pdfFile); PDF_close($pdfFile); PDF_delete($pdfFile); exit; } //start writing from the point 50,780 PDF_show_xy($pdfFile, "This Text In Arial Font", 50, 780); PDF_end_page($pdfFile); PDF_close($pdfFile); //store the pdf document in $pdf $pdf = PDF_get_buffer($pdfFile); //get the len to tell the browser about it $pdflen = strlen($pdfFile); //telling the browser about the pdf document
foreach ($row as $item) { echo $item; $b[$cnt] = $item; $cnt++; } } foreach ($invoice as $row) { $cnt = 0; foreach ($row as $item) { echo $item; $u[$cnt] = $item; $cnt++; } } $mypdf = PDF_new(); PDF_open_file($mypdf, ""); PDF_set_info($mypdf, "Creator", "Online Bus Service"); PDF_set_info($mypdf, "Author", "Mukesh Kumar"); PDF_set_info($mypdf, "Title", "Speedticket"); PDF_set_info($mypdf, "Subject", "Ticket"); PDF_set_info($mypdf, "Keywords", "Bus Ticket"); PDF_begin_page($mypdf, 595, 842); $myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0); PDF_setfont($mypdf, $myfont, 12); PDF_setcolor($mypdf, "stroke", "rgb", 0.5, 0.5, 0.5, 1); PDF_moveto($mypdf, 50, 810); PDF_lineto($mypdf, 500, 810); PDF_stroke($mypdf); PDF_moveto($mypdf, 50, 100); PDF_lineto($mypdf, 500, 100); PDF_stroke($mypdf);