<?php /*************************** Sample using a PHP array ****************************/ require 'fpdm.php'; $fields = array("name" => "My name", "address" => "My address", "city" => "My city", "phone" => "My phone number"); $pdf = new FPDM('template.pdf'); $pdf->Load($fields); $pdf->Merge(); $pdf->Output();
function mergePDF($template, $fields, $outfilename = "src_output.pdf") { $pdf = new FPDM($template); $pdf->Load($fields, true); // second parameter: false if field values are in ISO-8859-1, true if UTF-8 $pdf->Merge(); $pdf->Output($outfilename, "D"); }
<?php /*************************** Sample using a PHP array ****************************/ require 'fpdm.php'; $fields = array('name' => 'My name', 'address' => 'My address', 'city' => 'My city', 'phone' => 'My phone number'); $pdf = new FPDM('template.pdf'); $pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8 $pdf->Merge(); $pdf->Output();
<?php /*************************** Sample using an FDF file ****************************/ require 'fpdm.php'; $pdf = new FPDM('template.pdf', 'fields.fdf'); $pdf->Merge(); $pdf->Output();
' . $prodname[3] . ' ' . $poref[3] . ' ' . $prodname[4] . ' ' . $poref[4] . ' ' . $prodname[5] . ' ' . $poref[5] . ' ' . $prodname[6] . ' ' . $poref[6] . ' ' . $prodname[7] . ' ' . $poref[7]); $pdf = new FPDM('include/fpdm/opt_salesorder.pdf'); } else { $fields = array('tipodocumento' => $type, 'accountname' => $acc_name, 'trackingno' => $adb->query_result($result1, 0, 'nrtracking'), 'client_country' => $adb->query_result($result1, 0, 'acc_country'), 'client_address' => $bill_street, 'accountcap_city_prov' => $adb->query_result($result1, 0, 'acc_code') . ',' . $adb->query_result($result1, 0, 'acc_city') . ',' . $adb->query_result($result1, 0, 'acc_state'), 'accountvat' => 'P.IVA:' . $partitaiva . '', 'invoicenumber' => '', 'issuedate' => $date1, 'som_number' => $adb->query_result($result1, 0, 'nrdoc'), 'no1' => $nrline[0], 'productname1' => $prodname[0], 'quantity1' => $quantity[0], 'unitprice1' => $price[0], 'code1' => $adb->query_result($result1, 0, 'codice_articolo'), 'unit1' => '', 'amount1' => $tot[0], 'no2' => $nrline[1], 'productname2' => $prodname[1], 'quantity2' => $quantity[1], 'unitprice2' => $price[1], 'code2' => $adb->query_result($result1, 1, 'codice_articolo'), 'unit2' => '', 'amount2' => $tot[1], 'no3' => $nrline[2], 'productname3' => $prodname[2], 'quantity3' => $quantity[2], 'unitprice3' => $price[2], 'code3' => $adb->query_result($result1, 2, 'codice_articolo'), 'unit3' => '', 'amount3' => $tot[2], 'no4' => $nrline[3], 'productname4' => $prodname[3], 'quantity4' => $quantity[3], 'unitprice4' => $price[3], 'code4' => $adb->query_result($result1, 3, 'codice_articolo'), 'unit4' => '', 'amount4' => $tot[3], 'no5' => $nrline[4], 'productname5' => $prodname[4], 'quantity5' => $quantity[4], 'unitprice5' => $price[4], 'code5' => $adb->query_result($result1, 4, 'codice_articolo'), 'unit5' => '', 'amount5' => $tot[4], 'no6' => $nrline[5], 'productname6' => $prodname[5], 'quantity6' => $quantity[5], 'unitprice6' => $price[5], 'code6' => $adb->query_result($result1, 5, 'codice_articolo'), 'unit6' => '', 'amount6' => $tot[5], 'no7' => $nrline[6], 'productname7' => $prodname[6], 'quantity7' => $quantity[6], 'unitprice7' => $price[6], 'code7' => $adb->query_result($result1, 6, 'codice_articolo'), 'unit7' => '', 'amount7' => $tot[6], 'no8' => $nrline[7], 'productname8' => $prodname[7], 'quantity8' => $quantity[7], 'unitprice8' => $price[7], 'code8' => $adb->query_result($result1, 7, 'codice_articolo'), 'unit8' => '', 'amount8' => $tot[7], 'portofloading' => $adb->query_result($result1, 0, 'pol'), 'portofdischarge' => $adb->query_result($result1, 0, 'pod'), 'departuredate' => $adb->query_result($result1, 0, 'dtvessel'), 'vesselname' => $adb->query_result($result1, 0, 'vslname'), 'billoflading' => $adb->query_result($result1, 0, 'cf_1310'), 'sayinwords' => '', 'imponibile' => formatMoney($totiv, true), 'vat_amount' => formatMoney($subtot, true), 'valore' => formatMoney($totam, true), 'paymenttype' => $payment, 'totimponibilevat' => '$ ' . formatMoney($impiva, true), 'ivatotale' => '$ ' . formatMoney($subtot, true), 'nonimponibilevat' => '$ ' . formatMoney($nonimpiva, true), 'description' => $prodname[0] . ' ' . $poref[0] . ' ' . $prodname[1] . ' ' . $poref[1] . ' ' . $prodname[2] . ' ' . $poref[2] . ' ' . $prodname[3] . ' ' . $poref[3] . ' ' . $prodname[4] . ' ' . $poref[4] . ' ' . $prodname[5] . ' ' . $poref[5] . ' ' . $prodname[6] . ' ' . $poref[6] . ' ' . $prodname[7] . ' ' . $poref[7]); $pdf = new FPDM('include/fpdm/opt_fattura.pdf'); } //$pdf = new FPDM('include/fpdm/opt_salesorder.pdf'); $pdf->Load($fields, true); // second parameter: false if field values are in ISO-8859-1, true if UTF-8 $pdf->Merge(); //$file = 'storage/opt_levico08.pdf'; // // if (file_exists($file)) unlink($file); // $pdf->Output(); // $pdf->Output('storage/opt_fattura_levico.pdf','D'); // just require TCPDF instead of FPDF //require_once('include/fpdi/tcpdf.php'); //require_once('include/fpdi/fpdi.php'); //