function generate_philosophy_certificate($confirmation, $form, $entry, $ajax) { // print_r( $entry ); die; if ($entry['gquiz_is_pass']) { $upload_dir = wp_upload_dir(); // initiate FPDI $pdf = new FPDI(); // set the sourcefile $pdf->setSourceFile(get_template_directory() . '/library/certificate.pdf'); // import page 1 $tplIdx = $pdf->importPage(1); // get the width and height of the template $specs = $pdf->getTemplateSize($tplIdx); // add a page $pdf->AddPage("L", array($specs['w'], $specs['h'])); // use the imported page as the template $pdf->useTemplate($tplIdx, 0, 0); // now write some text above the imported page $pdf->SetY(101); $pdf->SetFont("dejavuserifbi", 'I', 35); $pdf->SetTextColor(0, 54, 99); $text = $entry['2.3'] . " " . $entry['2.6']; $pdf->MultiCell(260, 40, $text, 0, 'C'); // now write some text above the imported page $pdf->SetY(165); $pdf->SetFont("dejavuserifbi", 'I', 22); $pdf->SetTextColor(0, 54, 99); $text = date('F j, Y'); $pdf->MultiCell(260, 22, $text, 0, 'C'); // save the pdf out to file $pdf->Output($upload_dir['basedir'] . '/certificates/' . $entry['id'] . '.pdf', 'F'); } return array('redirect' => '/philosophy-results/?id=' . $entry['id']); }
$pdf->Cell(20); $texto = $row2["SA_OBSERVACIONES"]; $pdf->WordWrap($texto, 176); $texto = explode("\n", $texto); for ($i=0; $i<count($texto); $i++) { if ($i > 1) break; $str = trim($texto[$i]); $pdf->Cell(1); $pdf->Cell(0, 0, $str); $pdf->Ln(4.2); } $pdf->SetY(235.4); $pdf->SetX(76); $pdf->Cell(44, 0, $row2["SA_LUGARSUSCRIPCION"]); $pdf->Cell(10); $pdf->Cell(8, 0, $row2["DIASUSCRIPCION"]); $pdf->Cell(22); $pdf->Cell(27, 0, $row2["MESSUSCRIPCION"], 0, 0, "C"); $pdf->Cell(6); $pdf->Cell(10, 0, $row2["ANOSUSCRIPCION"]); $pdf->Ln(9.4); $pdf->Cell(24); $pdf->Cell(71, 0, $row2["NOMBRECOMERCIALIZADOR"]);
/** * Save post metadata when a post is saved. * * @param int $post_id The post ID. * @param post $post The post object. * @param bool $update Whether this is an existing post being updated or not. */ public function save_ticket_data($post_id, $post, $update) { global $product; /* * In production code, $slug should be set only once in the plugin, * preferably as a class property, rather than in each function that needs it. */ $slug = 'product'; // If this isn't a 'product' post, don't update it. if ($slug != $post->post_type) { return; } $getprod = get_product($post_id); //If it's not a ticket return aswell if ($getprod->product_type != 'ticket') { return; } $getmeta = get_post_meta($post_id, '_downloadable_files', true); //Traverse the return array since we don't know the first key foreach ($getmeta as $key => $value) { $url = $value['file']; } $path = $_SERVER['DOCUMENT_ROOT'] . parse_url($url, PHP_URL_PATH); //To get the dir, use: dirname($path) require_once 'fpdf/fpdf.php'; require_once 'fpdi/fpdi.php'; //Get stuff to add to pdf :D $getmetaall = get_post_meta($post_id); $getcontent = get_post_meta($post_id, 'frs_woo_product_tabs', true); $i = 1; $pdf = new FPDI(); // $pdf->AddPage(); //Set the source PDF file //$pagecount = $pdf->setSourceFile($path); //Import the first page of the file //$tpl = $pdf->importPage($i); //Use this page as template //$pdf->useTemplate($tpl); #Print Hello World at the bottom of the page //Clear all $pdf->SetFillColor(255, 255, 255); $pdf->SetY(1); $pdf->SetFont('Arial', 'I', 19); $pdf->Cell(0, $pdf->h - 2, ' ', 0, 0, 'C', true); //Go to 1.5 cm from bottom $pdf->SetY(1); //Select Arial italic 8 $pdf->SetFont('Arial', 'I', 19); //Print centered cell with a text in it $pdf->Cell(0, 10, $post->post_title, 0, 0, 'C'); /* $pdf->SetY(10); $pdf->SetFont('Arial','I',16); $pdf->Cell(0, 10, gmdate("Y-m-d", $getmetaall["wpcf-event-start-date"][0]), 0, 0, 'C'); $pdf->SetY(20); $pdf->SetFont('Arial','I',16); $pdf->Cell(0, 10, 'Start time: ' . $getmetaall["wpcf-event-start-time"][0], 0, 0, 'C'); $pdf->SetY(27); $pdf->SetFont('Arial','I',16); $pdf->Cell(0, 10, 'End time: ' . $getmetaall["wpcf-event-end-time"][0], 0, 0, 'C'); $pdf->SetY(1); $pdf->Image('http://dancenergy.zenutech.com/production/wp-content/uploads/2014/06/Logo.png', 5, 0, 33.78); */ //Select Arial italic 8 $pdf->SetY(20); $pdf->SetFont('Arial', 'I', 15); $pdf->WriteHTML($getcontent[0]['ticket_content']); $pdf->Output($path, "F"); /* echo "<pre>"; var_dump( $getmetaall ); echo "</pre>"; */ return; }
/** * Determine if the email should actually be sent and setup email merge variables * * @since 0.1 * @param int $order_id */ public function trigger($order_id) { global $woocommerce; // bail if no order ID is present if (!$order_id) { return; } // setup order object $this->object = new WC_Order($order_id); //check if is downloadbale if (!$this->object->has_downloadable_item()) { return; } // replace variables in the subject/headings $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); //To get the dir, use: dirname($path) require_once 'fpdf/fpdf.php'; require_once 'fpdi/fpdi.php'; if (!$this->is_enabled() || !$this->get_recipient()) { return; } $upload_dir = wp_upload_dir(); // Array of key => value pairs //cosntruct ticket temp dir $tickettemp = $upload_dir['basedir'] . '/tickets_temp'; if (!file_exists($tickettemp)) { mkdir($tickettemp, 0755, true); } $items = $this->object->get_items(); $varation_ids = array(); $metaorder = get_post_meta($this->object->id); $emaailid = $this->object->billing_email; $downloadlinks = array(); $i = 0; foreach ($items as $key => $value) { $x = 1; $getprod = $this->object->get_product_from_item($value); $getdownload = $this->object->get_item_downloads($value); if ($getprod->product_type != 'ticket') { break; } if (empty($getdownload)) { break; } $qty = intval($value['qty']); while ($x <= $qty) { $x++; foreach ($getdownload as $keysub => $valuesub) { $downlink = $valuesub['file']; } $path = $_SERVER['DOCUMENT_ROOT'] . parse_url($downlink, PHP_URL_PATH); $pdfout = $tickettemp . '/ticket_' . $this->object->id . '' . $value['product_id'] . '' . $x . '.pdf'; $downloadlinks[$i] = $pdfout; $pagenum = 1; $pdf = new FPDI(); $pdf->AddPage(); //Set the source PDF file $pagecount = $pdf->setSourceFile($path); //Import the first page of the file $tpl = $pdf->importPage($pagenum); //Use this page as template $pdf->useTemplate($tpl); $getfooterY = $pdf->h - 35; //Select Arial italic 8 $pdf->SetY($getfooterY); $pdf->SetFont('Arial', 'I', 10); $pdf->Cell(0, 10, 'Ticket id: ' . $this->object->id . '' . $value['product_id'] . '' . $x, 0, 0, 'C'); $pdf->Output($pdfout, "F"); $i++; } } /* $email_class = new WC_Email(); remove_action( 'woocommerce_after_resend_order_email', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); echo "<pre>"; var_dump( $this->emails ); echo "</pre>"; var_dump( $downloadlinks ); var_dump( $items ); var_dump( $emaailid); var_dump( $this->object ); */ // woohoo, send the email! $this->send($this->get_recipient() . ', ' . $this->object->billing_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $downloadlinks); //Delete the temp tickets foreach ($downloadlinks as $key => $value) { chmod($value, 0777); if (file_exists($value)) { unlink($value); } } //die(); }
$pdf->Text($repname[x], $repname[y], utf8_decode($firma["name"])); $pdf->Text($repstr[x], $repstr[y], utf8_decode($firma["street"])); $pdf->Text($report[x], $report[y], $firma["zipcode"] . " " . utf8_decode($firma["city"])); $pdf->Text($repphone[x], $repphone[y], $firma["phone"]); $pdf->Text($repaid[x], $repaid[y], $_GET["aid"]); $pdf->SetFont($repfont, '', $repsizeN); $pdf->Text($repwvnr[x], $repwvnr[y], $masch['contractnumber']); $pdf->Text($repkdnr[x], $repkdnr[y], $firma["customernumber"]); $pdf->Text($repdate[x], $repdate[y], date("d.m.Y")); $pdf->Text($repmasch[x], $repmasch[y], utf8_decode($masch["description"])); $pdf->Text($repser[x], $repser[y], $masch["serialnumber"]); $pdf->Text($repsort[x], $repsort[y], utf8_decode($masch["standort"])); $pdf->Text($repcnt[x], $repcnt[y], $masch["counter"]); $pdf->Text($repinsp[x], $repinsp[y], db2date($masch["inspdatum"])); $pdf->Text($repkurz[x], $repkurz[y], utf8_decode($rep["cause"])); $pdf->SetY($replang[x]); $pdf->SetX($replang[y]); $pdf->MultiCell(0, 6, utf8_decode($rep["schaden"]), 0); $pdf->addPage(); $history = "Die letzten Ereignisse:\n"; $history .= db2date($hist[0]["datum"]); $history .= " " . $hist[0]["art"] . " "; if ($hist[0]["art"] == "RepAuftr") { preg_match("/^[0-9]+\\|(.+)/", utf8_decode($hist[0]["beschreibung"]), $treffer); $history .= $treffer[1] . "\n"; } else { $history .= $hist[0]["beschreibung"] . "\n"; } $history .= db2date($hist[1]["datum"]); $history .= " " . $hist[1]["art"] . " "; if ($hist[1]["art"] == "RepAuftr") {
// Muestro el texto de arriba de las firmas.. $pdf->SetFont("Arial", "", 9); $pdf->Ln(4); $texto = explode("\n", "Por medio de la presente ".$row2["RAZON_SOCIAL"]." autoriza a Provincia ART S.A. a entregar a Provincia Seguros S.A. la información sobre la nómina (datos de Empleados, Masa Salarial, C.U.I.L., Nombre, etc.) e información complementaria que a criterio de la aseguradora permita tener un conocimiento de la actividad y del comportamiento del riesgo inherente a la cobertura."); for ($i=0; $i<count($texto); $i++) { $str = trim($texto[$i]); $pdf->WordWrap($str, 188); $pdf->Write(4, $str); $pdf->Ln(2); } $pdf->SetX(8); $pdf->SetY(250); $pdf->Cell(120, 0, "Buenos Aires, ".date("d")." de ".GetMonthName(date("m"))." de ".date("Y")); updateFechaImpresion((isset($idFormulario)?$idFormulario:0)); } else { $pdf->AddPage(); $pdf->SetTextColor(255, 0, 0); $pdf->SetFont("Arial", "B", 14); $pdf->Ln(30); $pdf->Cell(0, 0, $msgSqlVacio, 0, 0, "C"); } if ($autoPrint) $pdf->AutoPrint(false);
$i = 1; $netoAPagar = 0; while ($row = DBGetQuery($stmt)) { if (($i % MAX_REGISTROS_POR_HOJA) == 0) dibujarCabecera(); $pdf->Ln(4); $pdf->Cell(-5); $pdf->Cell(32, 0, $row["TIPO"], 0, 0, "C"); $pdf->Cell(20, 0, $row["FECHA"], 0, 0, "C"); $pdf->Cell(32, 0, $row["NUMERO"], 0, 0, "C"); $pdf->Cell(84, 0, $row["DESCRIPCION"], 0, 0, "C"); $pdf->Cell(32, 0, $row["MONTOFORMATEADO"], 0, 0, "R"); $netoAPagar+= str_replace(",", ".", $row["MONTO"]); $i++; } $pdf->SetY(272); $pdf->Ln(1); $pdf->Rect($pdf->GetX() - 5, $pdf->GetY(), 200, 0.2, "F"); $sql = "SELECT TO_CHAR(".$netoAPagar.", '$9,999,999,990.00') montoformateado FROM DUAL"; $pdf->SetFont("Arial", "B", 8); $pdf->Ln(2); $pdf->Cell(132); $pdf->Cell(20, 0, "Neto a Pagar:"); $pdf->Cell(43, 0, ValorSql($sql, 0, array()), 0, 0, "R"); $pdf->Output(); ?>
$pdf->Ln(16); $pdf->Cell(91); $pdf->Cell(170, 0, $rowCabecera["DOMICDESTINATARIO"]); $pdf->Ln(149); $pdf->Cell(-2); $pdf->Cell(9, 0, $rowPeriodos["PER_MES"], 0, 0, "C"); $pdf->Cell(-0.4); $pdf->Cell(11, 0, $rowPeriodos["PER_ANO"], 0, 0, "C"); $pdf->SetFont("Arial", "B", 14); $pdf->Cell(10); $pdf->Cell(85, 0, $rowPeriodos["TOTALFORMATEADO"], 0, 0, "C"); $pdf->SetY(196.4); $texto = strtoupper(numerosALetras(str_replace(",", ".", $rowPeriodos["TOTAL"]), 2, true)); $pdf->WordWrap($texto, 145); $texto = explode("\n", $texto); for ($i=0; $i<count($texto); $i++) { $str = trim($texto[$i]); $pdf->Cell(116); $pdf->Cell(0, 0, $str); $pdf->Ln(5); } } $pdf->Output("EC_Formulario_817.pdf", "I"); // ******* FIN - Armado del reporte.. ******* }
$pdf->Cell(14); $pdf->Cell(52, 0, $rowTelefonos["PROVINCIA"]); $pdf->Cell(36); $pdf->Cell(32, 0, $rowTelefonos["CODIGOPOSTAL"]); $pdf->Ln(5); $pdf->Cell(30); $pdf->Cell(32, 0, $rowTelefonos["LT_EMPLEADOS"]); $pdf->Cell(22); $pdf->Cell(116, 0, $rowTelefonos["TELEFONOS"]); } $pdf->SetY(226); $pdf->Cell(93); $pdf->Cell(28, 0, number_format($row2["CLAUSULAPENAL"], 0, ",", "."), 0, 0, "C"); $pdf->Cell(12); $pdf->Cell(62, 0, numerosALetras($row2["CLAUSULAPENAL"])); //Página 2.. $pdf->AddPage(); $tplIdx = $pdf->importPage(2); $pdf->useTemplate($tplIdx); // Tapo el N° de solicitud que está en el pdf original.. $pdf->SetDrawColor(255, 255, 255);
public function generatepdfAction(command $commande) { $request = $this->get('request'); $tools = $this->get('tools.utils'); $session = $request->getSession(); if ($session->has('tpl')) { $tpl = $commande->getToprint(); $pdffile = ""; foreach ($tpl as $key => $elemnt) { foreach ($elemnt as $val) { $prod = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($val['id']); $template = $prod->getTpl(); $tplpdf = str_replace("../", "", $template->getPdf()); $pdffile = $this->get('kernel')->getRootDir() . '/../web/' . $tplpdf; } } $custom_layout = array(85, 55); $orientation = 'L'; $pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false); $pdf->setPageOrientation($orientation); $pdf->SetMargins(0, 0, 0); $pdf->SetAutoPageBreak(true, 0); $pdf->setFontSubsetting(false); $pdf->AddPage($orientation); // echo "<pre>";print_r($pdf->getMargins());exit; $pdf->setSourceFile($pdffile); $_tplIdx = $pdf->importPage(1); $size = $pdf->useTemplate($_tplIdx, 0, 0, 85, 55, true); $idd = ""; $i = 0; $oldx = 0; $oldy = 0; foreach ($elemnt as $value) { //if($i==0) if ($idd != $value['id'] && $value['value'] != "") { $pdf->SetPageMark(); if (substr($value['value'], 0, 4) != "/tmp") { //$tools->dump($value); $align = strtoupper(substr($value['align'], 0, 1)); $color = $this->hex2rgb($value['color']); $pdf->SetTextColor($color[0], $color[1], $color[2]); $param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']); $y2 = $param->getX1() / 5; $x1 = $param->getY1() / 5; //$x1 = 10;$y2 = 8; $w = $param->getX2() / 5; $h = $param->getY2() / 5; $oldx = $x1; $oldy = $y2; $pdf->SetX($x1, false); $pdf->SetY($y2, false); //$pdf->SetXY($x1, $y2,true); $pdf->SetFont(null, '', $param->getSize() * 0.6); //$param->getPolice() // echo $opt->getFontsize()."\n"; $pdf->Cell($w, $h, $value["value"], 0, 0, $align); } else { $param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']); $img = $this->getParameter('base_url') . $value['value']; $pdf->Image($img, $param->getX1() / 4.5, $param->getY1() / 4.55, $param->getX2() / 4.55, $param->getY2() / 4.5, '', '', '', true); } } $idd = $value['id']; $i++; } //$pdf->Cell(0, $size['h'], 'TCPDF and FPDI'); // echo $template->getId(); $pdf->Output($this->get('kernel')->getRootDir() . '/../web/pdf.pdf'); } return new Response(""); }
$ende = $rep["endedatum"] == $rep["anfangdatum"] ? "offen" : db2date($rep["endedatum"]); $hdl = $pdf->ImportPage(1); $pdf->addPage(); $pdf->useTemplate($hdl); $pdf->SetFont($wvfont, '', $wvsize); $pdf->Text($wvname[x], $wvname[y], utf8_decode($firma["name"])); $pdf->Text($wvstr[x], $wvstr[y], utf8_decode($firma["street"])); $pdf->Text($wvort[x], $wvort[y], $firma["zipcode"] . " " . utf8_decode($firma["city"])); $pdf->Text($wvkdnr[x], $wvkdnr[y], $firma["customernumber"]); $pdf->Text($wvwvnr[x], $wvwvnr[y], $rep['contractnumber']); $pdf->Text($wvstart[x], $wvstart[y], db2date($rep["anfangdatum"])); $pdf->Text($wvende[x], $wvende[y], $ende); $pdf->Text($wvbetrag[x], $wvbetrag[y], sprintf("%0.2f", $rep["betrag"])); $pdf->SetFont('Helvetica', '', 10); $bem = $rep["bemerkung"] ? utf8_decode($rep["bemerkung"]) : "Es werden keine Sondervereinbarungen getroffen"; $pdf->SetY($wvbem[y]); $pdf->SetX($wvbem[x]); $pdf->MultiCell(0, 6, $bem, 0); for ($j = 2; $j <= $seiten; $j++) { $hdl = @$pdf->ImportPage($j); $pdf->addPage(); $pdf->useTemplate($hdl); } $pdf->SetFont($wvfont, '', $wvsize); $i = 300; $p = 1; foreach ($masch as $row) { if ($i > 270) { $pdf->addPage(); $pdf->Text($wvkopf[x], $wvkopf[y], "Anhang A (Seite {$p}) zum Wartungsvertrag " . $rep['contractnumber'] . " vom " . db2date($rep["anfangdatum"])); $i = 40;
/** * we redifine the original SetY method, because we don't want the automatic treatment. * It is HTML2PDF that make the treatment * * @param float $y * @param boolean $resetx Reset the X position * @param boolean $rtloff NOT USED * @access public */ public function SetY($y, $resetx = true, $rtloff = false) { if (!$rtloff and $this->rtl) { parent::SetY($y, $resetx, $rtloff); } else { if ($resetx) { $this->x = $this->lMargin; } $this->y = $y; } }