public function testPdfOutput() { // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 029'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 029', PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) $pdf->setLanguageArray($this->langSettings); // --------------------------------------------------------- // set array for viewer preferences $preferences = array('HideToolbar' => true, 'HideMenubar' => true, 'HideWindowUI' => true, 'FitWindow' => true, 'CenterWindow' => true, 'DisplayDocTitle' => true, 'NonFullScreenPageMode' => 'UseNone', 'ViewArea' => 'CropBox', 'ViewClip' => 'CropBox', 'PrintArea' => 'CropBox', 'PrintClip' => 'CropBox', 'PrintScaling' => 'AppDefault', 'Duplex' => 'DuplexFlipLongEdge', 'PickTrayByPDFSize' => true, 'PrintPageRange' => array(1, 1, 2, 3), 'NumCopies' => 2); // Check the example n. 60 for advanced page settings // set pdf viewer preferences $pdf->setViewerPreferences($preferences); // set font $pdf->SetFont('times', '', 14); // add a page $pdf->AddPage(); // print a line $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 1', 1, 1, 'C'); $pdf->Ln(5); $pdf->Write(0, 'You can use the setViewerPreferences() method to change viewer preferences.', '', 0, 'L', true, 0, false, false, 0); // add a page $pdf->AddPage(); // print a line $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 2', 0, 0, 'C'); // add a page $pdf->AddPage(); // print a line $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 3', 0, 0, 'C'); $this->comparePdfs($pdf); }
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set display mode $pdf->SetDisplayMode($zoom = 'fullpage', $layout = 'TwoColumnRight', $mode = 'UseNone'); // set pdf viewer preferences $pdf->setViewerPreferences(array('Duplex' => 'DuplexFlipLongEdge')); // set booklet mode $pdf->SetBooklet(true, 10, 30); // set core font $pdf->SetFont('helvetica', '', 18); // add a page (left page) $pdf->AddPage(); $pdf->Write(0, 'Example of booklet mode', '', 0, 'L', true, 0, false, false, 0); // print a line using Cell() $pdf->Cell(0, 0, 'PAGE 1', 1, 1, 'C'); // add a page (right page) $pdf->AddPage(); // print a line using Cell() $pdf->Cell(0, 0, 'PAGE 2', 1, 1, 'C'); // add a page (left page) $pdf->AddPage();
// set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- $preferences = array('HideToolbar' => true, 'HideMenubar' => true, 'HideWindowUI' => true, 'FitWindow' => true, 'CenterWindow' => true, 'DisplayDocTitle' => true, 'NonFullScreenPageMode' => 'UseNone', 'ViewArea' => 'CropBox', 'ViewClip' => 'CropBox', 'PrintArea' => 'CropBox', 'PrintClip' => 'CropBox', 'PrintScaling' => 'AppDefault', 'Duplex' => 'DuplexFlipLongEdge', 'PickTrayByPDFSize' => true, 'PrintPageRange' => array(1, 1, 2, 3), 'NumCopies' => 2); // set pdf viewer preferences $pdf->setViewerPreferences($preferences); // set font $pdf->SetFont('times', '', 14); // add a page $pdf->AddPage(); // print a line $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 1', 0, 0, 'C'); // add a page $pdf->AddPage(); // print a line $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 2', 0, 0, 'C'); // add a page $pdf->AddPage(); // print a line $pdf->Cell(0, 12, 'DISPLAY PREFERENCES - PAGE 3', 0, 0, 'C'); // ---------------------------------------------------------
function loanPaperWorkPDF() { $this->loan->LoanNumber = $this->loaninfo['LoanNumber']; $this->Address(); $this->LoanAgentString(); $this->preptypes = array('Sheet' => 'sheet', 'Packet' => 'packet', 'Microscope slide' => 'microscope slide', 'Spirit' => 'spirit jar', 'Cibachrome' => 'cibachrome', 'Photograph of specimen' => 'photograph', 'Type' => 'type'); $this->LoanSummaryString(); $this->loanPrepHeader = array('LoanNumber' => $this->loan->LoanNumber, 'LoanAgent' => $this->LoanAgents, 'ShipmentDate' => $this->loaninfo['ShipmentDate'], 'LoanPrepSummary' => $this->LoanSummaryString()); $pdf = new TCPDF(); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Niels Klazenga'); $pdf->SetTitle('MEL Label'); $pdf->SetSubject('MEL Label'); //set margins $pdf->SetMargins(25, 37, 25); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, 15); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->setViewerPreferences(array('FitWindow' => true)); // set font $pdf->SetFont('helvetica', '', 10); // set cell padding $pdf->setCellPaddings(0, 0, 0, 0); // set cell margins $pdf->setCellMargins(0, 0, 0, 0); // start loan cover letter $pdf->AddPage(); $image_file = base_url() . 'images/loans_paperwork_background.png'; $pdf->Image($image_file, 163, 0, 30, 0, 'PNG', '', 'T', true, 300, '', false, false, 0, false, false, false); $pdf->MultiCell(120, 5, $this->loaninfo['ShipmentDate'], 0, 'L', 0, 1, 25, 15, true, false, true); $pdf->MultiCell(120, 5, $this->loan->ShippedTo, 0, 'L', 0, 1, 25, 22, true, false, true); $pdf->MultiCell(125, 5, '<span style="font-size:16pt;font-weight:bold">MEL loan ' . $this->loan->LoanNumber . '</span>', 0, 'L', 0, 1, 25, 65, true, false, true); $pdf->MultiCell(130, 1, '<hr/>', 0, 'L', 0, 1, 22.5, $pdf->GetY() + 1, true, false, true); $w = 30; $y = $pdf->GetY() - 2; $pdf->MultiCell($w, 5, 'For study by:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->LoanAgents, 0, 'L', 0, 1, 30 + $w, $y, true, false, true); $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Description:', 0, 'L', 0, 1, 25, $y, true, false, true); $description = $this->loaninfo['Description']; if (strpos($description, '||')) { $description = substr($description, 0, strpos($description, '||')); } $description = trim($description); $pdf->MultiCell(120 - $w, 5, $description, 0, 'L', 0, 1, 30 + $w, $y, true, false, true); $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Quantity:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->Quantity(), 0, 'L', 0, 1, 30 + $w, $y, true, false, true); $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Due date:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->loaninfo['CurrentDueDate'], 0, 'L', 0, 1, 30 + $w, $y, true, false, true); $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Shipment details:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->loaninfo['ShipmentMethod'], 0, 'L', 0, 1, 30 + $w, $y, true, false, true); if ($this->loaninfo['TrackingLabels']) { $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Tracking label(s):', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->loaninfo['TrackingLabels'], 0, 'L', 0, 1, 30 + $w, $y, true, false, true); } $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Loan conditions:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, 'See attached. ' . $this->loaninfo['SpecialConditions'], 0, 'L', 0, 1, 30 + $w, $y, true, false, true); $pdf->MultiCell(130, 5, '<hr/>', 0, 'L', 0, 1, 22.5, $pdf->GetY() + 1, true, false, true); $paragraphs = array(); $paragraphs[] = <<<EOD Please verify the contents of the loan against the attached specimen list and acknowledge receipt by returning the yellow copy of this form. Any damage in transit should be noted on the yellow form. EOD; $paragraphs[] = <<<EOD This loan should be returned to MEL by the date shown above. An extension may be granted on request. EOD; if (strstr($this->LoanAgents, ' and ')) { $c = 'comply'; } else { $c = 'complies'; } $paragraphs[] = <<<EOD Please ensure that {$this->LoanAgents} {$c} with the enclosed loan conditions. EOD; $paragraphs[] = <<<EOD Electronic data for the specimens in this loan is available on request. For queries relating to loans, exchange or donations, please email MEL at herbmel@rbg.vic.gov.au. EOD; foreach ($paragraphs as $para) { $pdf->Multicell(125, 5, $para, 0, 'J', 0, 1, 25, $pdf->GetY() + 1, true, false, true); } $pdf->MultiCell(125, 5, $this->loaninfo['ShippedBy'] . ' on behalf of the Collections Manager', 0, 'L', 0, 1, 25, $pdf->GetY() + 8, true, false, true); $y = 231; //$image_file = base_url() . 'images/scissors.png'; //$pdf->Image($image_file, 22, $y-2.5, 5, 5, 'PNG', '', 'T', false, 300, '', false, false, 0, false, false, false); //$pdf->MultiCell(127, 5, '<hr/>', 0, 'L', 0, 1, 25.5, $y, true, false, true); $pdf->MultiCell(130, 5, '<hr/>', 0, 'L', 0, 1, 22.5, $y, true, false, true); $y = $pdf->GetY() - 1; $pdf->MultiCell(45, 5, 'Number of parcels: ' . $this->loaninfo['NumberOfPackages'], 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(75, 5, 'Number of specimens: ' . $this->Quantity(), 0, 'L', 0, 1, 75, $y, true, false, true); $pdf->MultiCell(125, 5, 'Material received in good condition.', 0, 'L', 0, 1, 25, $pdf->GetY() + 3, true, false, true); $y = $pdf->GetY() + 3; $pdf->MultiCell(25, 5, 'Comments: ', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(105, 5, '<hr/>', 0, 'L', 0, 1, 45, $y + 4, true, false, true); $pdf->MultiCell(125, 5, '<hr/>', 0, 'L', 0, 1, 25, $pdf->GetY() + 1, true, false, true); $pdf->MultiCell(125, 5, '<hr/>', 0, 'L', 0, 1, 25, $pdf->GetY() + 1, true, false, true); $y = $pdf->GetY() + 1; $pdf->MultiCell(35, 5, 'Receiving officer:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(60, 5, '<hr/>', 0, 'L', 0, 1, 53, $y + 4, true, false, true); $pdf->MultiCell(15, 5, 'Date: ', 0, 'L', 0, 1, 115, $y, true, false, true); $pdf->MultiCell(25, 5, '<hr/>', 0, 'L', 0, 1, 125, $y + 4, true, false, true); $pdf->setY(0); $x = 165; $pdf->SetFont('helvetica', '', 7); $letterh = <<<EOD <div style="color:#999999">National Herbarium of Victoria (MEL)<br />Birdwood Avenue<br /> South Yarra<br /> Victoria 3141<br /> Australia </div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, 60, true, false, true); $letterh = <<<EOD <div style="color:#999999">CITES<br />AU 026</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">Telephone<br />(03) 9252 2300</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">Facsimile<br />(03) 9252 2413</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">Email<br />herbmel@rbg.vic.gov.au</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">Web<br/ >www.rbg.vic.gov.au/science</div> EOD; $pdf->MultiCell(31, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">The Royal Botanic Gardens Board (Victoria)</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 111, true, false, true); $letterh = <<<EOD <div style="color:#999999">Patron<br />Dame Elisabeth Murdoch</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">Incorporating:</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 5, true, false, true); $letterh = <<<EOD <div style="color:#999999">Royal Botanic Gardens Melbourne</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">National Herbarium of Victoria</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">Royal Botanic Gardens Cranbourne</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); $letterh = <<<EOD <div style="color:#999999">Australian Research Centre for Urban Ecology</div> EOD; $pdf->MultiCell(30, 5, $letterh, 0, 'L', 0, 1, $x, $pdf->getY() + 1, true, false, true); // move pointer to last page $pdf->lastPage(); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('loan.pdf', 'I'); }
public function invoicedownloadAction() { //error_reporting(E_ALL); //ini_set('display_errors', 1); error_reporting(0); $renderer = new PhpRenderer(); //whole TCPDF's settings goes here $id = $this->params()->fromQuery('id'); $lang_code = $this->params()->fromRoute('lang'); // Get Project $entityManager = $this->getEntityManager(); $project = $entityManager->find('\\User\\Entity\\Project', (int) $id); $project_data = $project->getData(); $types = $project_data['types']; $hasTypeTranslationNoTM = 0; $hasTypeTranslationUseTM = 0; $hasTypeDesktopPublishingWin = 0; $hasTypeDesktopPublishingMac = 0; $hasTypeDesktopPublishingEngineer = 0; $hasTypeDesktopPublishingInterpreting = 0; foreach ($types as $type) { if ($type == 1) { $hasTypeTranslationNoTM = 1; } else { if ($type == 2) { $hasTypeTranslationUseTM = 1; } else { if ($type == 3) { $hasTypeDesktopPublishingWin = 1; } else { if ($type == 4) { $hasTypeDesktopPublishingMac = 1; } else { if ($type == 5) { $hasTypeDesktopPublishingEngineer = 1; } else { if ($type > 5) { $hasTypeDesktopPublishingInterpreting = 1; } } } } } } } if ($project_data['serviceLevel'] == 1) { $serviceLevel = "Professional"; } else { if ($project_data['serviceLevel'] == 2) { $serviceLevel = "Business"; } else { if ($project_data['serviceLevel'] == 3) { $serviceLevel = "Premium"; } } } //get invoice $repository = $entityManager->getRepository('User\\Entity\\Invoice'); $invoice = $repository->findBy(array('project' => $project)); $invoices = array(); foreach ($invoice as $k => $v) { $invoices[$k] = $v->getData(); } $invoices['invoice_no'] = "INV-" . $project_data["project_no"]; $invoices = $invoices[0]; $invoiceDate = ''; $dueDate = ''; if ($invoices['invoiceDate']) { $invoiceDate = $invoices['invoiceDate']->format('d M Y'); } if ($invoices['dueDate']) { $dueDate = $invoices['dueDate']->format('d M Y'); } //Get company info if ($project_data['currency'] == 'cny') { $companyinfo = $entityManager->find('\\Admin\\Entity\\ProfileInfo', 1); } else { $companyinfo = $entityManager->find('\\Admin\\Entity\\ProfileInfo', 2); } //$companyinfo = $entityManager->find('\Admin\Entity\ProfileInfo', 1); //Get bank info if ($project_data['currency'] == 'cny') { $bankinfo = $entityManager->find('\\Admin\\Entity\\ProfileBank', 1); } else { $bankinfo = $entityManager->find('\\Admin\\Entity\\ProfileBank', 2); } $subtotal = 0; //get iterm translation $repository = $entityManager->getRepository('User\\Entity\\Itermnotm'); $iterm_translation = $repository->findBy(array('project' => $project)); $iterm_translations = array(); foreach ($iterm_translation as $k => $v) { $iterm_translations[$k] = $v->getData(); if ($hasTypeTranslationNoTM == 1) { $subtotal = $subtotal + $iterm_translations[$k]['total']; } } //get iterm translationtm $repository = $entityManager->getRepository('User\\Entity\\Itermtm'); $iterm_translationtm = $repository->findBy(array('project' => $project)); $iterm_translationtms = array(); foreach ($iterm_translationtm as $k => $v) { $tmp = $v->getData(); $iterm_translationtms[$tmp['language']['id']] = $v->getData(); if ($hasTypeTranslationUseTM == 1) { $subtotal = $subtotal + $iterm_translationtms[$k]['total']; } } //get iterm iterm_dtppcs $repository = $entityManager->getRepository('User\\Entity\\Itermdtppc'); $iterm_dtppc = $repository->findBy(array('project' => $project)); $iterm_dtppcs = array(); foreach ($iterm_dtppc as $k => $v) { $tmp = $v->getData(); if ($tmp['unit'] == 1) { $tmp['unit'] = 'Day'; } else { $tmp['unit'] = 'Half Day'; } $iterm_dtppcs[$k] = $tmp; if ($hasTypeDesktopPublishingWin == 1) { $subtotal = $subtotal + $iterm_dtppcs[$k]['total']; } } //get iterm iterm_dtpmac $repository = $entityManager->getRepository('User\\Entity\\Itermdtpmac'); $iterm_dtpmac = $repository->findBy(array('project' => $project)); $iterm_dtpmacs = array(); foreach ($iterm_dtpmac as $k => $v) { $tmp = $v->getData(); if ($tmp['unit'] == 1) { $tmp['unit'] = 'Day'; } else { $tmp['unit'] = 'Half Day'; } $iterm_dtpmacs[$k] = $tmp; if ($hasTypeDesktopPublishingMac == 1) { $subtotal = $subtotal + $iterm_dtpmacs[$k]['total']; } } // Get Interpreting Price $repository = $entityManager->getRepository('User\\Entity\\Iterminterpreting'); $iterm_interpreting = $repository->findBy(array('project' => $project)); $iterm_interpretings = array(); foreach ($iterm_interpreting as $k => $v) { $tmp = $v->getData(); if ($tmp['unit'] == 1) { $tmp['unit'] = 'Day'; } else { if ($tmp['unit'] == 2) { $tmp['unit'] = 'Half Day'; } } $iterm_interpretings[$k] = $tmp; if ($hasTypeDesktopPublishingInterpreting == 1) { $subtotal = $subtotal + $iterm_interpretings[$k]['total']; } } // Get Itermengineering $repository = $entityManager->getRepository('User\\Entity\\Itermengineering'); $iterm_engineering = $repository->findBy(array('project' => $project)); $iterm_engineerings = array(); foreach ($iterm_engineering as $k => $v) { $tmp = $v->getData(); if ($tmp['unit'] == 1) { $tmp['unit'] = 'Hour'; } else { if ($tmp['unit'] == 2) { $tmp['unit'] = 'Day'; } else { if ($tmp['unit'] == 3) { $tmp['unit'] = 'Month'; } else { if ($tmp['unit'] == 4) { $tmp['unit'] = 'Word'; } else { if ($tmp['unit'] == 5) { $tmp['unit'] = 'Graphic'; } else { $tmp['unit'] = 'Page'; } } } } } $iterm_engineerings[$k] = $tmp; if ($hasTypeDesktopPublishingEngineer == 1) { $subtotal = $subtotal + $iterm_engineerings[$k]['total']; } } $view = $this->getServiceLocator()->get('Zend\\View\\Renderer\\RendererInterface'); $viewModel = new ViewModel(); $template = '/admin/project/invoicedownload'; $viewModel->setTemplate($template)->setVariables(array('id' => $id, 'lang_code' => $lang_code, 'project' => $project->getData(), 'companyinfo' => $companyinfo->getData(), 'bankinfo' => $bankinfo ? $bankinfo->getData() : null, 'hasTypeTranslationNoTM' => $hasTypeTranslationNoTM, 'hasTypeTranslationUseTM' => $hasTypeTranslationUseTM, 'hasTypeDesktopPublishingWin' => $hasTypeDesktopPublishingWin, 'hasTypeDesktopPublishingMac' => $hasTypeDesktopPublishingMac, 'hasTypeDesktopPublishingEngineer' => $hasTypeDesktopPublishingEngineer, 'hasTypeDesktopPublishingInterpreting' => $hasTypeDesktopPublishingInterpreting, 'iterm_translations' => $iterm_translations, 'iterm_translationtms' => $iterm_translationtms, 'iterm_dtppcs' => $iterm_dtppcs, 'iterm_dtpmacs' => $iterm_dtpmacs, 'iterm_interpretings' => $iterm_interpretings, 'iterm_engineerings' => $iterm_engineerings, 'serviceLevel' => $serviceLevel, 'subtotal' => $subtotal, 'invoices' => $invoices, 'dueDate' => $dueDate, 'invoiceDate' => $invoiceDate))->setTerminal(true); //return $viewModel; $content = $view->render($viewModel); // set array for viewer preferences $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $font = new \TCPDF_FONTS(); //$fontx = $font->addTTFfont('public/fonts/STHeiti-Light.ttc'); //$pdf->SetFont($fontx, '', 12, '', false); //$pdf->SetFont('microsoftyahei' , '', 12,'',false); $pdf->SetFont('droidsansfallback', '', 7); $pdf->setFontSubsetting(true); $preferences = array('HideToolbar' => true, 'HideMenubar' => true, 'HideWindowUI' => true, 'FitWindow' => true, 'CenterWindow' => true, 'DisplayDocTitle' => true, 'NonFullScreenPageMode' => 'UseNone', 'ViewArea' => 'CropBox', 'ViewClip' => 'CropBox', 'PrintArea' => 'CropBox', 'PrintClip' => 'CropBox', 'PrintScaling' => 'AppDefault', 'Duplex' => 'DuplexFlipLongEdge', 'PickTrayByPDFSize' => true, 'PrintPageRange' => array(1, 1, 2, 3), 'NumCopies' => 2); // set pdf viewer preferences $pdf->setViewerPreferences($preferences); // add a page $pdf->AddPage(); // output the HTML content $pdf->writeHTML($content, true, false, true, false, ''); $pdf->lastPage(); $name = "INV-" . $project_data['project_no'] . ".pdf"; ob_end_clean(); $pdf->Output($name, 'D'); //$pdf->Output("pdf-name.pdf", 'D'); exit; }
protected function btnPrint_Click() { if ($this->lstLabelStock->SelectedValue) { $this->lstLabelStock->Warning = ""; set_time_limit(0); // If the user clicked Cancel button if ($_SESSION["intGeneratingStatus"] != -1) { // If the user clicked outside of the modal dialog if ($this->dlgPrintLabels->Visible && $this->dlgPrintLabels->Display) { if ($this->intCurrentBarCodeLabel < count($this->strBarCodeArray)) { array_push($this->strTablesBufferArray, $this->CreateTableByBarCodeArray()); $this->txtWarning->Text = "Please wait... PDF Generating: " . $_SESSION["intGeneratingStatus"] . "% Complete"; $this->txtWarning->Display = true; $this->btnPrint->Enabled = true; QApplication::ExecuteJavaScript("document.getElementById('" . $this->btnPrint->ControlId . "').click();"); } else { include_once '../includes/php/tcpdf/config/lang/eng.php'; include_once '../includes/php/tcpdf/tcpdf.php'; $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); // Set document information $pdf->SetCreator("Tracmor"); $pdf->SetAuthor("Tracmor"); $pdf->SetTitle("Bar Codes"); // Set PDF viewer preferences $arrPreferences = array('PrintScaling' => 'None'); $pdf->setViewerPreferences($arrPreferences); // Disable header and footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // Disable auto page breaks $pdf->SetAutoPageBreak(false); // Set some language-dependent strings $pdf->setLanguageArray($l); // Set the color used for all drawing operations (lines, rectangles and cell borders). $pdf->SetDrawColor(255); // white // Set Cell Padding $pdf->SetCellPadding(0); // Set Cell Spacing $pdf->SetLineWidth(0); // Initialize document $pdf->AliasNbPages(); switch ($this->lstLabelStock->SelectedValue) { case 1: // Labels per row for Avery 6577 (5/8" x 3") $pdf->SetFontSize(3); $pdf->setCellHeightRatio(2.3); // was 1.93 // Set margins $pdf->SetMargins(12, 12, 12); break; case 2: // Labels per row for Avery 6576 (1-1/4" x 1-3/4") $pdf->SetFontSize(3); $pdf->setCellHeightRatio(11.0); // was 10.2 // Set margins $pdf->SetMargins(10, 16, 10); break; default: throw new QCallerException('Label Stock Not Provided'); break; } foreach ($this->strTablesBufferArray as $strTableBuffer) { // add a page $pdf->AddPage(); // output the HTML content $pdf->writeHTML($strTableBuffer); } // Close and save PDF document $pdf->Output(".." . __TRACMOR_TMP__ . "/" . $_SESSION['intUserAccountId'] . "_BarCodes.pdf", "F"); // Cleaning up $this->btnCancel_Click(); // Uncheck all items but SelectAll checkbox foreach ($this->GetAllControls() as $objControl) { if (substr($objControl->ControlId, 0, 11) == 'chkSelected') { $objControl->Checked = false; } } $arrDataGridObjectNameId = $this->ctlSearchMenu->GetDataGridObjectNameId(); // Uncheck SelectAll checkbox $this->ctlSearchMenu->{$arrDataGridObjectNameId}[0]->chkSelectAll->Checked = false; // Open generated PDF in new window QApplication::ExecuteJavaScript("window.open('.." . __TRACMOR_TMP__ . "/" . $_SESSION['intUserAccountId'] . "_BarCodes.pdf','Barcodes','resizeable,menubar=1,scrollbar=1,left=0,top=0,width=800,height=600');"); } } else { // Cleaning up $this->btnCancel_Click(); } } } else { $this->lstLabelStock->Warning = "Please select one"; $this->lstLabelStock->Enabled = true; } }
/** * */ function buildOutput() { require_once Mage::getBaseDir() . '/lib/tcpdf/config/tcpdf_config.php'; require_once Mage::getBaseDir() . '/lib/tcpdf/config/lang/eng.php'; require_once Mage::getBaseDir() . '/lib/tcpdf/tcpdf.php'; $this->tmpType = 'pdf'; $printerMargin = 0; $this->layoutInfo = array('leftMargin' => 0.15625, 'topMargin' => 0.5, 'rightMargin' => 0.15625, 'labelPadding' => 0.125); if ($printerMargin > $this->layoutInfo['leftMargin']) { $this->layoutInfo['labelPadding'] = $printerMargin - $this->layoutInfo['leftMargin']; $this->layoutInfo['leftMargin'] = 0; } else { $this->layoutInfo['leftMargin'] -= $printerMargin; } if ($printerMargin > $this->layoutInfo['topMargin']) { $this->layoutInfo['topMargin'] = 0; } else { $this->layoutInfo['topMargin'] -= $printerMargin; } if ($printerMargin > $this->layoutInfo['rightMargin']) { $this->layoutInfo['rightMargin'] = 0; } else { $this->layoutInfo['rightMargin'] -= $printerMargin; } $this->layoutInfo['labelPage'] = false; if ($this->labelsType == '5160' || $this->labelsType == '8160-s' || $this->labelsType == '8160-b' || $this->labelsType == 'barcodes') { $this->layoutInfo['labelPage'] = '8160'; $this->layoutInfo['RowsPerPage'] = 10; $this->layoutInfo['ColsPerRow'] = 3; $this->layoutInfo['labelHeight'] = 1; $this->layoutInfo['labelWidth'] = 2.625; $this->layoutInfo['labelSpacerWidth'] = 0.15625; $this->layoutInfo['barcodeMaxWidth'] = $this->layoutInfo['labelWidth'] - $this->layoutInfo['labelPadding'] * 2; $this->layoutInfo['barcodeMaxHeight'] = $this->layoutInfo['labelHeight'] - $this->layoutInfo['labelPadding'] * 2; $this->layoutInfo['barcodeMaxHeight'] -= 0.125; //Allow For Text if ($this->labelsType == '5160' || $this->labelsType == '8160-s') { $buildfunction = 'buildLabel_Address'; } elseif ($this->labelsType == 'barcodes' || $this->labelsType == '8160-b') { $buildfunction = 'buildLabel_Barcodes'; } } elseif ($this->labelsType == '5164' || $this->labelsType == '8164') { $this->layoutInfo['labelPage'] = '8164'; $this->layoutInfo['RowsPerPage'] = 3; $this->layoutInfo['ColsPerRow'] = 2; $this->layoutInfo['labelHeight'] = 3.3125; $this->layoutInfo['labelWidth'] = 4; $this->layoutInfo['labelSpacerWidth'] = 0.1875; $this->layoutInfo['barcodeMaxWidth'] = $this->layoutInfo['labelWidth'] - $this->layoutInfo['labelPadding'] * 2; $this->layoutInfo['barcodeMaxHeight'] = 1; $this->layoutInfo['barcodeMaxHeight'] -= 0.125; //Allow For Text $buildfunction = 'buildLabel_ProductInfo'; } if ($this->layoutInfo['labelPage'] !== false) { $this->pdf = new TCPDF('P', 'in', array('8.5', '11.2'), true); $this->pdf->SetCreator('Rental Extension'); $this->pdf->SetAuthor('Cristian Arcu'); $this->pdf->SetTitle('Rental Product Labels'); $this->pdf->SetSubject('Rental Product Labels'); $this->pdf->setViewerPreferences(array('PrintScaling' => 'None')); $this->pdf->SetMargins($this->layoutInfo['leftMargin'], $this->layoutInfo['topMargin'], $this->layoutInfo['rightMargin'], true); $this->pdf->SetCellPadding($this->layoutInfo['labelPadding']); $this->pdf->setPrintHeader(false); $this->pdf->setPrintFooter(false); $this->pdf->SetAutoPageBreak(TRUE, 0.51); $this->pdf->setImageScale(1); //$this->pdf->setLanguageArray($l); //$this->pdf->AliasNbPages(); $this->pdf->AddPage(); $this->pdf->SetFont("helvetica", "", 11); $CurPage = 1; $CurrentRow = 1; $CurrentCol = 1; $labelCnt = 0; $lastLabel = sizeof($this->labels); while ($CurrentRow <= $this->layoutInfo['RowsPerPage']) { if (!isset($this->labels[$labelCnt])) { break; } if ($CurPage == 1) { if ($CurrentRow < $this->startLocation['row']) { $blankRow = true; } else { $blankRow = false; } } else { $blankRow = false; } while ($CurrentCol <= $this->layoutInfo['ColsPerRow']) { //if ($CurPage == 1){ if (!isset($this->labels[$labelCnt])) { break; } if ($blankRow === true || $CurrentCol < $this->startLocation['col']) { $blankCol = true; } else { //Reset to 1 so that after first output it will continue without skipping columns $this->startLocation['col'] = 1; $blankCol = false; } /*} else { $blankCol = false; }*/ $newLine = $CurrentCol == $this->layoutInfo['ColsPerRow'] ? 1 : 0; if ($blankCol === true) { $lInfo = array(); } else { $lInfo = $this->labels[$labelCnt]; $labelCnt++; } $this->{$buildfunction}($lInfo, $newLine); $CurrentCol++; } $CurrentCol = 1; $CurrentRow++; if ($CurrentRow == $this->layoutInfo['RowsPerPage']) { if ($lastLabel > $labelCnt) { $CurrentRow = 1; $CurPage++; } } } $this->pdf->lastPage(); $this->pdf->Output("labelSheet.pdf", "I"); die; } else { die('PDF Error: Unknown Label Sheet Type (' . $this->labelsType . ')'); } }
function exchangePaperWorkPDF() { $this->loan->GiftNumber = $this->loaninfo['GiftNumber']; $this->Address(); $this->LoanAgentString(); $this->preptypes = array('Duplicate' => 'duplicate', 'Seed duplicate' => 'seed duplicate', 'Silica gel sample' => 'silica gel sample', 'Shipping material' => 'shipping material', 'Type' => 'type'); $this->exchangeSummaryString(); $this->loanPrepHeader = array('ExchangeNumber' => $this->loan->GiftNumber, 'LoanAgent' => $this->LoanAgents, 'ShipmentDate' => $this->loaninfo['ShipmentDate'], 'LoanPrepSummary' => $this->exchangeSummaryString()); $pdf = new TCPDF(); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Niels Klazenga'); $pdf->SetTitle('MEL Label'); $pdf->SetSubject('MEL Label'); //set margins $pdf->SetMargins(25, 37, 25); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, 15); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->setViewerPreferences(array('FitWindow' => true)); // set font $pdf->SetFont('helvetica', '', 10); // set cell padding $pdf->setCellPaddings(0, 0, 0, 0); // set cell margins $pdf->setCellMargins(0, 0, 0, 0); // start loan cover letter $pdf->AddPage(); $pdf->Image('images/mel-letterhead.jpg', 25, 0, '', '', '', '', 'T', true, 300, '', false, false, 0, false, false, false); $pdf->MultiCell(120, 5, $this->loaninfo['ShipmentDate'], 0, 'L', 0, 1, 25, 15, true, false, true); $pdf->MultiCell(120, 5, $this->loan->ShippedTo, 0, 'L', 0, 1, 25, 22, true, false, true); $pdf->MultiCell(130, 5, '<span style="font-size:16pt;font-weight:bold">MEL ' . $this->loaninfo['ExchangeType'] . ' to ' . $this->loaninfo['Acronym'] . ' (MEL ref.' . $this->loan->GiftNumber . ')</span>', 0, 'L', 0, 1, 25, 65, true, false, true); $pdf->MultiCell(130, 1, '<hr/>', 0, 'L', 0, 1, 22.5, $pdf->GetY() + 1, true, false, true); $w = 30; $y = $pdf->GetY() - 2; if ($this->loaninfo['GiftAgents']) { $pdf->MultiCell($w, 5, 'Attention:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(130 - $w, 5, $this->loaninfo['GiftAgents'], 0, 'L', 0, 1, 30 + $w, $y, true, false, true); $y = $pdf->GetY() + 1; } $pdf->MultiCell($w, 5, 'Description:', 0, 'L', 0, 1, 25, $y, true, false, true); $description = $this->loaninfo['Description']; if (strpos($description, '||')) { $description = substr($description, 0, strpos($description, '||')); } $description = trim($description); $pdf->MultiCell(120 - $w, 5, $description, 0, 'L', 0, 1, 30 + $w, $y, true, false, true); $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Quantity:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->Quantity(), 0, 'L', 0, 1, 30 + $w, $y, true, false, true); if ($this->loaninfo['ExchangeType'] != 'shipping material') { $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Electronic data:', 0, 'L', 0, 1, 25, $y, true, false, true); if ($this->LoanAgents) { $when = $this->loaninfo['ShipmentDate']; $what = $this->loaninfo['ExchangeFileName']; $text = $what . ' emailed to ' . $this->LoanAgents; } else { $text = 'Available on request'; } $pdf->MultiCell(120 - $w, 5, $text, 0, 'L', 0, 1, 30 + $w, $y, true, false, true); } $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Shipment details:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->loaninfo['ShipmentMethod'], 0, 'L', 0, 1, 30 + $w, $y, true, false, true); if ($this->loaninfo['TrackingLabels']) { $y = $pdf->GetY() + 1; $pdf->MultiCell($w, 5, 'Tracking label(s):', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(120 - $w, 5, $this->loaninfo['TrackingLabels'], 0, 'L', 0, 1, 30 + $w, $y, true, false, true); } $pdf->MultiCell(130, 5, '<hr/>', 0, 'L', 0, 1, 22.5, $pdf->GetY() + 1, true, false, true); $paragraphs = array(); $paragraphs[] = <<<EOD Please verify the contents of this consignment against the attached specimen list and acknowledge receipt by returning the yellow copy of this form. EOD; $paragraphs[] = <<<EOD For queries relating to loans, exchange or donations, please email MEL at herbmel@rbg.vic.gov.au. EOD; foreach ($paragraphs as $para) { $pdf->Multicell(125, 5, $para, 0, 'J', 0, 1, 25, $pdf->GetY() + 1, true, false, true); } $pdf->MultiCell(125, 5, $this->loaninfo['ShippedBy'] . ' on behalf of the Collections Manager', 0, 'L', 0, 1, 25, $pdf->GetY() + 8, true, false, true); $y = 231; $pdf->MultiCell(130, 5, '<hr/>', 0, 'L', 0, 1, 22.5, $y, true, false, true); $y = $pdf->GetY() - 1; $pdf->MultiCell(45, 5, 'Number of parcels: ' . $this->loaninfo['NumberOfPackages'], 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(75, 5, 'Number of specimens: ' . $this->Quantity(), 0, 'L', 0, 1, 75, $y, true, false, true); $pdf->MultiCell(125, 5, 'Material received in good condition.', 0, 'L', 0, 1, 25, $pdf->GetY() + 3, true, false, true); $y = $pdf->GetY() + 3; $pdf->MultiCell(25, 5, 'Comments: ', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(105, 5, '<hr/>', 0, 'L', 0, 1, 45, $y + 4, true, false, true); $pdf->MultiCell(125, 5, '<hr/>', 0, 'L', 0, 1, 25, $pdf->GetY() + 1, true, false, true); $pdf->MultiCell(125, 5, '<hr/>', 0, 'L', 0, 1, 25, $pdf->GetY() + 1, true, false, true); $y = $pdf->GetY() + 1; $pdf->MultiCell(35, 5, 'Receiving officer:', 0, 'L', 0, 1, 25, $y, true, false, true); $pdf->MultiCell(60, 5, '<hr/>', 0, 'L', 0, 1, 53, $y + 4, true, false, true); $pdf->MultiCell(15, 5, 'Date: ', 0, 'L', 0, 1, 115, $y, true, false, true); $pdf->MultiCell(25, 5, '<hr/>', 0, 'L', 0, 1, 125, $y + 4, true, false, true); $pdf->Output('exchange.pdf', 'I'); }
public function update() { $db = $this->getDb(); $stm = $db->prepare('SELECT p.idproduto, p.produto, if(pn.quantidade_nf IS NULL, qta_sum_1, pn.quantidade_nf) AS quantidade_nf, pn.valor_unit_nf, p.tipo, pn.data_1, pn.data_2 FROM produto p LEFT JOIN (SELECT idp_1, (qta_1-qta_2) AS quantidade_nf, pn_1.valor_unit_nf, data_1, data_2 FROM (select idproduto AS idp_1, sum(quantidade_nf) AS qta_1, valor_unit_nf, data AS data_1 FROM produto_por_nota INNER JOIN (SELECT nf_fornecedor AS nf, data FROM nota_fiscal WHERE tipo_nota = 1 AND data >= :data_inicio_1 AND data <= :data_final_1 ) AS nff on nff.nf = nf_fornecedor GROUP BY idproduto ) pn_1, (select idproduto AS idp_2, sum(quantidade_nf) AS qta_2, data_2 FROM produto_por_nota INNER JOIN (SELECT nf_fornecedor AS nf_2, data AS data_2 FROM nota_fiscal WHERE tipo_nota = 2 AND data >= :data_inicio_2 AND data <= :data_final_2 ) AS nff on nff.nf_2 = nf_fornecedor GROUP BY idproduto ) pn_2 WHERE idp_1 = idp_2 ) AS pn ON pn.idp_1 = p.idproduto LEFT JOIN (select idproduto AS idp_sum_1, sum(quantidade_nf) AS qta_sum_1, valor_unit_nf AS valor_unit_nf_sum FROM produto_por_nota WHERE nf_fornecedor IN (SELECT nf_fornecedor FROM nota_fiscal WHERE tipo_nota = 1) GROUP BY idproduto ) AS pn_sum_1 ON pn_sum_1.idp_sum_1 = idproduto'); $stm->bindValue(':data_inicio_1', $_SESSION['data_inicio']); $stm->bindValue(':data_final_1', $_SESSION['data_fim']); $stm->bindValue(':data_inicio_2', $_SESSION['data_inicio']); $stm->bindValue(':data_final_2', $_SESSION['data_fim']); $stm->execute(); $result = $stm->fetchAll(PDO::FETCH_ASSOC); if (isset($result[0]['tipo'])) { for ($i = 0; isset($result[$i]['tipo']); $i++) { switch ($result[$i]['tipo']) { case 1: $result[$i]['tipo'] = 'UN'; break; case 2: $result[$i]['tipo'] = 'LT'; break; case 3: $result[$i]['tipo'] = 'PC'; break; case 4: $result[$i]['tipo'] = 'OT'; break; } } } if (isset($result[0]['data_1'])) { for ($i = 0; isset($result[$i]['data_1']); $i++) { $result[$i]['data_1'] = implode(preg_match("~\\/~", $result[$i]['data_1']) == 0 ? "/" : "-", array_reverse(explode(preg_match("~\\/~", $result[$i]['data_1']) == 0 ? "-" : "/", $result[$i]['data_1']))); } } if (isset($result[0]['data_2'])) { for ($i = 0; isset($result[$i]['data_2']); $i++) { $result[$i]['data_2'] = implode(preg_match("~\\/~", $result[$i]['data_2']) == 0 ? "/" : "-", array_reverse(explode(preg_match("~\\/~", $result[$i]['data_2']) == 0 ? "-" : "/", $result[$i]['data_2']))); } } // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $data_inicio = explode('-', $_SESSION['data_inicio']); $data_fim = explode('-', $_SESSION['data_fim']); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetTitle('Inventário Período: ' . $data_inicio[2] . '/' . $data_inicio[1] . '/' . $data_inicio[0] . ' até ' . $data_fim[2] . '/' . $data_fim[1] . '/' . $data_fim[0]); // set default header data $pdf->SetHeaderData('', '', 'Inventário de ' . $data_inicio[2] . '/' . $data_inicio[1] . '/' . $data_inicio[0] . ' até ' . $data_fim[2] . '/' . $data_fim[1] . '/' . $data_fim[0], ''); // $pdf->setFooterData($tc=array(0,64,0), $lc=array(0,64,128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings // $pdf->setLanguageArray($l); // -------------------------------------------------------------------------------------------------------- // set array for viewer preferences $preferences = array('HideToolbar' => true, 'HideMenubar' => true, 'HideWindowUI' => true, 'FitWindow' => true, 'CenterWindow' => true, 'DisplayDocTitle' => true, 'NonFullScreenPageMode' => 'UseNone', 'ViewArea' => 'CropBox', 'ViewClip' => 'CropBox', 'PrintArea' => 'CropBox', 'PrintClip' => 'CropBox', 'PrintScaling' => 'AppDefault', 'Duplex' => 'DuplexFlipLongEdge', 'PickTrayByPDFSize' => true, 'PrintPageRange' => array(1, 1, 2, 3), 'NumCopies' => 2); // Check the example n. 60 for advanced page settings // set pdf viewer preferences $pdf->setViewerPreferences($preferences); // set font $pdf->SetFont('times', '', 14); // add a page $pdf->AddPage(); $pdf->Cell(0, 12, 'INVENTÁRIO', 1, 1, 'C'); $tbl = '<table cellspacing="0" cellpadding="1" border="1"> <tr> <td width="159" align="center" style="font-weight:bold">Produto</td> <td align="center" style="font-weight:bold">Quantidade</td> <td align="center" style="font-weight:bold">Valor Unit.</td> <td align="center" style="font-weight:bold">Tipo</td> </tr> </table>'; for ($i = 0; isset($result[$i]['idproduto']); $i++) { $tbl .= '<table cellspacing="0" cellpadding="1" border="1"> <tr> <td width="159" style="font-size:12pt">' . $result[$i]['produto'] . '</td> <td align="center" style="font-size:12pt">' . $result[$i]['quantidade_nf'] . '</td> <td align="center" style="font-size:12pt">' . $result[$i]['valor_unit_nf'] . '</td> <td align="center" style="font-size:12pt">' . $result[$i]['tipo'] . '</td> </tr> </table>'; } $pdf->writeHTML($tbl, true, false, false, false, ''); $pdf->Ln(5); //Close and output PDF document $pdf->Output('inventario periodo_' . $_SESSION['data_inicio'] . '_ate_' . $_SESSION['data_fim'] . '.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+ echo json_encode(array("success" => true, "message" => "Inventário gerado com sucesso!")); }
public function testPdfOutput() { // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 040'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 040', PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) $pdf->setLanguageArray($this->langSettings); // --------------------------------------------------------- // set display mode $pdf->SetDisplayMode($zoom = 'fullpage', $layout = 'TwoColumnRight', $mode = 'UseNone'); // set pdf viewer preferences $pdf->setViewerPreferences(array('Duplex' => 'DuplexFlipLongEdge')); // set booklet mode $pdf->SetBooklet(true, 10, 30); // set core font $pdf->SetFont('helvetica', '', 18); // add a page (left page) $pdf->AddPage(); $pdf->Write(0, 'Example of booklet mode', '', 0, 'L', true, 0, false, false, 0); // print a line using Cell() $pdf->Cell(0, 0, 'PAGE 1', 1, 1, 'C'); // add a page (right page) $pdf->AddPage(); // print a line using Cell() $pdf->Cell(0, 0, 'PAGE 2', 1, 1, 'C'); // add a page (left page) $pdf->AddPage(); // print a line using Cell() $pdf->Cell(0, 0, 'PAGE 3', 1, 1, 'C'); // add a page (right page) $pdf->AddPage(); // print a line using Cell() $pdf->Cell(0, 0, 'PAGE 4', 1, 1, 'C'); $this->comparePdfs($pdf); }