Example #1
2
 /**
  * Merge multiple documents.
  *
  * @return Dhl_Intraship_Helper_Pdf             $this
  * @throws Dhl_Intraship_Helper_Pdf_Exception
  */
 public function merge()
 {
     // Include required fpdi library.
     if (!class_exists('FPDF', false)) {
         require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdf.php';
     }
     if (!class_exists('FPDI', false)) {
         require_once Mage::getBaseDir('base') . DS . 'lib' . DS . 'fpdf' . DS . 'fpdi.php';
     }
     // Try to merge documents via FPDI.
     try {
         // Create new FPDI document
         $this->_document = new FPDI('P', 'mm', $this->getConfig()->getFormat());
         $this->_document->SetAutoPageBreak(false);
         $page = 1;
         foreach ($this->_collection as $document) {
             $pages = $this->_document->setSourceFile($document->getFilePath());
             for ($i = 1; $i <= $pages; $i++) {
                 $this->_document->addPage();
                 $this->_document->useTemplate($this->_document->importPage($i, '/MediaBox'));
                 $page++;
             }
         }
     } catch (Exception $e) {
         throw new Dhl_Intraship_Helper_Pdf_Exception('pdf merging failed. service temporary not available', $e->getCode());
     }
     return $this;
 }
function generate_mitgliedsbescheinigung($titleAndName, $strasse, $plz, $ort, $land, $jahr, $vorstand, $datum)
{
    // initiate FPDI
    $pdf = new FPDI();
    // add a page
    $pdf->AddPage();
    // set the source file
    $pdf->setSourceFile(HOME_DIRECTORY . 'alumpiHP_libraries/Mitgliedsbestaetigung_blank.pdf');
    // import page 1
    $tplIdx = $pdf->importPage(1);
    // use the imported page and place it at position 0,0 with a width of 210 mm (full page)
    $pdf->useTemplate($tplIdx, 0, 0, 210);
    // add the font DejaVu
    $pdf->AddFont('DejaVuSans', '', 'DejaVuSans.ttf', true);
    $pdf->AddFont('DejaVuSans-Bold', '', 'DejaVuSans-Bold.ttf', true);
    // text settings
    $pdf->SetTextColor(0, 0, 0);
    // add address of the member
    $addressString = $titleAndName . "\n";
    $addressString .= $strasse . "\n";
    $addressString .= $plz . " " . $ort . "\n";
    $addressString .= $land;
    $pdf->SetFont('DejaVuSans');
    $pdf->SetFontSize(12);
    $pdf->SetXY(20, 23);
    $pdf->Multicell(80, 6, $addressString);
    //add heading
    $headingString = "Mitgliedsbescheinigung " . $jahr;
    $pdf->SetFont('DejaVuSans-Bold');
    $pdf->SetFontSize(16);
    $pdf->SetXY(20, 80);
    $pdf->Multicell(170, 6, $headingString);
    // add main text
    $textString = "Hiermit wird bestätigt, dass " . $titleAndName . " im Kalenderjahr " . $jahr;
    $textString .= " ordentliches Mitglied des Absolventen- und Förderverein MPI Uni Bayreuth e.V. (aluMPI) ist.\n";
    $textString .= "\n";
    $pdf->SetFont('DejaVuSans');
    $pdf->SetFontSize(12);
    $pdf->SetXY(20, 100);
    $pdf->Multicell(170, 6, $textString);
    // add signature text
    $signatureString = "Absolventen- und Förderverein MPI Uni Bayreuth e.V.\n";
    $signatureString .= "1. Vorstand: " . $vorstand . "\n";
    $pdf->SetXY(20, 140);
    $pdf->Multicell(170, 6, $signatureString);
    // add signature
    $pdf->Image(HOME_DIRECTORY . 'alumpiHP_libraries/unterschrift_krinninger.png', 20, 155, 50);
    // add place and date
    $dateString = "Bayreuth, " . $datum;
    $pdf->SetXY(20, 180);
    $pdf->Multicell(170, 6, $dateString);
    ob_clean();
    $pdf->Output();
}
Example #3
1
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']);
}
Example #4
1
 /**
  * Handle the event.
  *
  * @param  BookPublished $event
  * @return void
  */
 public function handle(CreateChapter $event)
 {
     // create PDF
     $fpdi = new \FPDI();
     // count the book page
     $pageCount = $fpdi->setSourceFile($this->uploadPath . $event->chapter->url);
     // this one is used within the CreatePDF to include it within the template
     Session::put('total_pages', $pageCount);
     // update the database with total page count
     $event->chapter->update(['total_pages' => $pageCount]);
     $event->chapter->save();
 }
 public function runProcessStep($dokument)
 {
     $file = $dokument->getLatestRevision()->getFile();
     $extension = array_pop(explode(".", $file->getExportFilename()));
     #$this->ziphandler->addFile($file->getAbsoluteFilename(), $file->getExportFilename());
     // Print Metainfo for PDFs
     if (strtolower($extension) == "pdf") {
         try {
             $fpdf = new FPDI();
             $pagecount = $fpdf->setSourceFile($file->getAbsoluteFilename());
             $fpdf->SetMargins(0, 0, 0);
             $fpdf->SetFont('Courier', '', 8);
             $fpdf->SetTextColor(0, 0, 0);
             $documentSize = null;
             for ($i = 0; $i < $pagecount; $i++) {
                 $string = $dokument->getLatestRevision()->getIdentifier() . " (Seite " . ($i + 1) . " von " . $pagecount . ", Revision " . $dokument->getLatestRevision()->getRevisionID() . ")";
                 $fpdf->AddPage();
                 $tpl = $fpdf->importPage($i + 1);
                 $size = $fpdf->getTemplateSize($tpl);
                 // First Page defines documentSize
                 if ($documentSize === null) {
                     $documentSize = $size;
                 }
                 // Center Template on Document
                 $fpdf->useTemplate($tpl, intval(($documentSize["w"] - $size["w"]) / 2), intval(($documentSize["h"] - $size["h"]) / 2), 0, 0, true);
                 $fpdf->Text(intval($documentSize["w"]) - 10 - $fpdf->GetStringWidth($string), 5, $string);
             }
             $this->ziphandler->addFromString($dokument->getLatestRevision()->getIdentifier() . "." . $extension, $fpdf->Output("", "S"));
         } catch (Exception $e) {
             $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
         }
     } else {
         $this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
     }
 }
Example #6
0
 public function createPDF(FPDI $fpdi, $filename)
 {
     $fpdi->setSourceFile(__DIR__ . '/A.pdf');
     $template = $fpdi->importPage(1);
     $size = $fpdi->getTemplateSize($template);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     $template = $fpdi->importPage(1);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     file_put_contents($filename, $fpdi->Output('', 'S'));
 }
Example #7
0
 public function listAction()
 {
     $receipt = new \FPDI();
     // PDFの余白(上左右)を設定
     $receipt->SetMargins(0, 0, 0);
     // ヘッダーの出力を無効化
     $receipt->setPrintHeader(false);
     // フッターの出力を無効化
     $receipt->setPrintFooter(false);
     // フォントを登録
     $fontPathRegular = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-regular.ttf';
     //         $regularFont = $receipt->addTTFfont($fontPathRegular, '', '', 32);
     $font = new TCPDF_FONTS();
     $regularFont = $font->addTTFfont($fontPathRegular);
     $fontPathBold = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-bold.ttf';
     //         $boldFont = $receipt->addTTFfont($fontPathBold, '', '', 32);
     $font = new TCPDF_FONTS();
     $boldFont = $font->addTTFfont($fontPathBold);
     // ページを追加
     $receipt->AddPage();
     // テンプレートを読み込み
     //         $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/receipt.pdf');
     //         $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/template.pdf');
     //         $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/w01_1.pdf');
     $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/senijiten.pdf');
     // 読み込んだPDFの1ページ目のインデックスを取得
     $tplIdx = $receipt->importPage(1);
     // 読み込んだPDFの1ページ目をテンプレートとして使用
     $receipt->useTemplate($tplIdx, null, null, null, null, true);
     // 書き込む文字列のフォントを指定
     $receipt->SetFont($regularFont, '', 11);
     // 書き込む文字列の文字色を指定
     $receipt->SetTextColor(0, 0, 255);
     // X : 42mm / Y : 108mm の位置に
     $receipt->SetXY(59, 248);
     // 文字列を書き込む
     $receipt->Write(0, isset($_POST['name']) ? $_POST['name'] . 'さん' : '名無しさん');
     /*         $response = new Response(
                 // Output関数の第一引数にはファイル名、第二引数には出力タイプを指定する
                 // 今回は文字列で返してほしいので、ファイル名はnull、出力タイプは S = String を選択する
                 $receipt->Output(null, 'S'),
                 200,
                 array('content-type' => 'application/pdf')
             );
     
             // レスポンスヘッダーにContent-Dispositionをセットし、ファイル名をreceipt.pdfに指定
             $response->headers->set('Content-Disposition', 'attachment; filename="receipt.pdf"');
     
             return $response;
      */
     //         $receipt->
     $receipt->output('newpdf.pdf', 'I');
 }
 public function testMerge()
 {
     $fpdi = new FPDI();
     $fpdi->setSourceFile(__DIR__ . '/A.pdf');
     $template = $fpdi->importPage(1);
     $size = $fpdi->getTemplateSize($template);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     $template = $fpdi->importPage(1);
     $fpdi->AddPage('P', array($size['w'], $size['h']));
     $fpdi->useTemplate($template);
     file_put_contents(__DIR__ . '/AA.pdf', $fpdi->Output('', 'S'));
 }
Example #9
0
function split_pdf($filename, $end_directory = false, $num = 1)
{
    require_once 'fpdf/fpdf.php';
    require_once 'fpdi/fpdi.php';
    $end_directory = $end_directory ? $end_directory . date("d-m-Y__H-i-s") . "/" : './';
    $new_path = preg_replace('/[\\/]+/', '/', $end_directory . '/' . substr($filename, 0, strrpos($filename, '/')));
    if (!is_dir($new_path)) {
        // Will make directories under end directory that don't exist
        // Provided that end directory exists and has the right permissions
        mkdir($new_path, 0777, true);
    }
    $pdf = new FPDI();
    $pagecount = $pdf->setSourceFile($filename);
    // How many pages?
    $j = 0;
    // Split each page into a new PDF
    $new_pdf = new FPDI();
    for ($i = 1; $i <= $pagecount; $i++) {
        $new_pdf->AddPage();
        $new_pdf->setSourceFile($filename);
        $new_pdf->useTemplate($new_pdf->importPage($i));
        if ($i != 1 && $i % $num == 0 || $num == 1) {
            try {
                $new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . $i . ".pdf";
                $new_pdf->Output($new_filename, "F");
                $url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/";
                echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n";
            } catch (Exception $e) {
                echo 'Caught exception: ', $e->getMessage(), "\n";
            }
            unset($new_pdf);
            $new_pdf = new FPDI();
            $j = 0;
        }
        $j++;
    }
    if ($j != 0) {
        try {
            $new_filename = $end_directory . str_replace('.pdf', '', $filename) . '_' . ($i - 1) . ".pdf";
            $new_pdf->Output($new_filename, "F");
            $url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']) . "/";
            echo "File: <a href='" . $url . $new_filename . "'>" . $url . $new_filename . "</a><br />\n";
        } catch (Exception $e) {
            echo 'Caught exception: ', $e->getMessage(), "\n";
        }
    }
}
Example #10
0
 /**
  * Merges your provided PDFs and outputs to specified location.
  * @param $outputmode
  * @param $outputname
  * @return PDF
  */
 public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf')
 {
     if (!isset($this->_files) || !is_array($this->_files)) {
         throw new exception("No PDFs to merge.");
     }
     $fpdi = new FPDI();
     //$fpdi->setPrintHeader(FALSE);
     //$fpdi->setPrintFooter(FALSE);
     //merger operations
     foreach ($this->_files as $file) {
         $filename = $file[0];
         $filepages = $file[1];
         $count = $fpdi->setSourceFile($filename);
         //add the pages
         if ($filepages == 'all') {
             for ($i = 1; $i <= $count; $i++) {
                 $template = $fpdi->importPage($i);
                 $size = $fpdi->getTemplateSize($template);
                 $orientation = $size['w'] <= $size['h'] ? 'P' : 'L';
                 $fpdi->AddPage($orientation, array($size['w'], $size['h']));
                 $fpdi->useTemplate($template);
             }
         } else {
             foreach ($filepages as $page) {
                 if (!($template = $fpdi->importPage($page))) {
                     throw new exception("Could not load page '{$page}' in PDF '{$filename}'. Check that the page exists.");
                 }
                 $size = $fpdi->getTemplateSize($template);
                 $orientation = $size['w'] <= $size['h'] ? 'P' : 'L';
                 $fpdi->AddPage($orientation, array($size['w'], $size['h']));
                 $fpdi->useTemplate($template);
             }
         }
     }
     //output operations
     $mode = $this->_switchmode($outputmode);
     if ($mode == 'S') {
         return $fpdi->Output($outputpath, 'S');
     } else {
         if ($fpdi->Output($outputpath, $mode) == '') {
             return true;
         } else {
             throw new exception("Error outputting PDF to '{$outputmode}'.");
             return false;
         }
     }
 }
Example #11
0
function carl_merge_pdfs_fpdi($pdffiles, $titles = array(), $metadata = array(), $metadata_encoding = 'UTF-8')
{
    // FPDI throws some notices that break the PDF
    $old_error = error_reporting(E_ERROR | E_WARNING | E_PARSE);
    include_once INCLUDE_PATH . 'pdf/tcpdf/tcpdf.php';
    include_once INCLUDE_PATH . 'pdf/fpdi/fpdi.php';
    if (gettype($pdffiles) != 'array') {
        trigger_error('$pdffiles must be an array');
        return false;
    }
    if (!(class_exists('TCPDF') && class_exists('FPDI'))) {
        trigger_error('You must have TCPDF/FPDI installed in order to run carl_merge_pdfs()');
        return false;
    }
    if (empty($pdffiles)) {
        return NULL;
    }
    $fpdi = new FPDI();
    foreach ($pdffiles as $pdffile) {
        if (file_exists($pdffile)) {
            $count = $fpdi->setSourceFile($pdffile);
            for ($i = 1; $i <= $count; $i++) {
                $template = $fpdi->importPage($i);
                $size = $fpdi->getTemplateSize($template);
                $fpdi->AddPage('P', array($size['w'], $size['h']));
                $fpdi->useTemplate($template, null, null, null, null, true);
                if ($i == 1) {
                    if (isset($titles[$pdffile])) {
                        $bookmark = html_entity_decode($titles[$pdffile]);
                    } else {
                        $bookmark = $pdffile;
                    }
                    $fpdi->Bookmark($bookmark, 1, 0, '', '', array(0, 0, 0));
                }
            }
        }
    }
    error_reporting($old_error);
    return $fpdi->Output('ignored.pdf', 'S');
}
Example #12
0
 function split_multi_pdf($arrayOfFiles)
 {
     $new_path = storage_path() . '/Macyspos';
     if (!is_dir($new_path)) {
         // Will make directories under end directory that don't exist
         // Provided that end directory exists and has the right permissions
         mkdir($new_path, 0777, true);
     }
     foreach ($arrayOfFiles as $file) {
         $tempArrayOfPos = array();
         $tempArrayOfPos = $this->getArrayOfPOs($file);
         $pdf = new FPDI();
         $pagecount = $pdf->setSourceFile($file);
         // How many pages?
         for ($i = 1; $i <= $pagecount; $i++) {
             $singleItem = $tempArrayOfPos[$i - 1];
             //   dd($singleItem);
             $tempPackingList = MacysPackingList::where('po', '=', $singleItem['PO'])->first();
             if ($tempPackingList == null) {
                 $new_pdf = new FPDI();
                 $new_pdf->AddPage();
                 $new_pdf->setSourceFile($file);
                 $newPackingList = new MacysPackingList();
                 $newPackingList->po = trim($singleItem['PO']);
                 $newPackingList->shipterms = trim($singleItem['shipterms']);
                 $new_pdf->useTemplate($new_pdf->importPage($i));
                 try {
                     $new_filename = storage_path() . '/Macyspos/' . $singleItem['PO'] . '.pdf';
                     $newPackingList->pathToFile = $new_filename;
                     $new_pdf->Output($new_filename, "F");
                     $newPackingList->save();
                 } catch (Exception $e) {
                     echo 'Caught exception: ', $e->getMessage(), "\n";
                 }
             }
         }
     }
 }
Example #13
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $id = $input->getArgument('id');
     $pdffile = $input->getArgument('pdf');
     $em = $this->getContainer()->get('doctrine');
     $tab = $this->csv($pdffile);
     $template = $em->getRepository('PrintBundle:Template')->find($id);
     $path = $this->getContainer()->get('kernel')->getRootDir() . '/../web/uploads/pdf/' . $template->getPdffile();
     $width = $template->getWidth();
     $height = $template->getHeight();
     $orientation = $height > $width ? 'P' : 'L';
     $custom_layout = array($width, $height);
     $i = 1;
     foreach ($tab as $key => $value) {
         $pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false);
         $pdf->setPageOrientation($orientation);
         $pdf->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT);
         $pdf->SetAutoPageBreak(true, 40);
         $pdf->setFontSubsetting(false);
         // add a page
         $pdf->AddPage($orientation);
         $pdf->setSourceFile($path);
         $_tplIdx = $pdf->importPage(1);
         $size = $pdf->useTemplate($_tplIdx, 0, 0, $width, true);
         foreach ($template->getChildactivity() as $opt) {
             $pdf->SetXY($opt->getX(), $opt->getY());
             $pdf->SetFont($opt->getFont(), '', $opt->getFontsize() * 2);
             // echo $opt->getFontsize()."\n";
             $pdf->Cell($opt->getWidth(), $opt->getHeight(), $value[$opt->getName()]);
         }
         //$pdf->Cell(0, $size['h'], 'TCPDF and FPDI');
         // echo $template->getId();
         $pdf->Output($this->getContainer()->get('kernel')->getRootDir() . '/../web/folder/pdf' . $template->getId() . "-{$i}.pdf", 'F');
         $i++;
     }
 }
Example #14
0
 protected function splitPages($pages)
 {
     if (!isset($pages) || empty($pages) || !is_array($pages)) {
         static::raiseError(__METHOD__ . '(), $pages parameter is invalid!');
         return false;
     }
     try {
         $pdf = new \FPDI();
     } catch (\Exception $e) {
         static::raiseError(__METHOD__ . '(), failed to load FPDI!');
         return false;
     }
     if (($fqfn = $this->tempItem->getFilePath()) === false) {
         static::raiseError(get_class($this->tempItem) . '::getFilePath() returned false!');
         return false;
     }
     try {
         $page_count = $pdf->setSourceFile($fqfn);
     } catch (\Exception $e) {
         static::raiseError(getClass($pdf) . '::setSourceFile() has thrown an exception! ' . $e->getMessage());
         return false;
     }
     if ($page_count == count($pages)) {
         try {
             @$pdf->cleanUp();
         } catch (\Exception $e) {
             static::raiseError(get_class($pdf) . '::cleanUp() has thrown an exception! ' . $e->getMessage());
             return false;
         }
         return true;
     }
     for ($page_no = 1; $page_no <= $page_count; $page_no++) {
         if (!in_array($page_no, $pages)) {
             continue;
         }
         // import a page
         $templateId = $pdf->importPage($page_no);
         // get the size of the imported page
         $size = $pdf->getTemplateSize($templateId);
         // create a page (landscape or portrait depending on the imported page size)
         if ($size['w'] > $size['h']) {
             $pdf->AddPage('L', array($size['w'], $size['h']));
         } else {
             $pdf->AddPage('P', array($size['w'], $size['h']));
         }
         // use the imported page
         $pdf->useTemplate($templateId);
     }
     try {
         $pdf->Output($fqfn, 'F');
     } catch (\Exception $e) {
         static::raiseError(get_class($pdf) . '::Output() returned false!');
         return false;
     }
     if (!$this->tempItem->refresh()) {
         static::raiseError(get_class($this->tempItem) . '::refresh() returned false!');
         return false;
     }
     return true;
 }
$idFormulario = ValorSql($sql, "", $params);

$params = array(":sa_idformulario" => $idFormulario);
$sql =
	"SELECT art.utiles.armar_cuit(sa_cuit) cuit, sa_nombre
		 FROM asa_solicitudafiliacion
		WHERE sa_idformulario = :sa_idformulario";
$stmt = DBExecSql($conn, $sql, $params);
$row2 = DBGetQuery($stmt, 1, false);

if ($autoPrint)
	$pdf = new PDF_AutoPrint();
else
	$pdf = new FPDI();

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/ventanilla_electronica.pdf");

$pdf->AddPage();
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->SetFont("Arial", "B", 9);

$pdf->Ln(34.5);
$pdf->Cell(38);
$pdf->Cell(136, 0, $row2["SA_NOMBRE"]);

$pdf->Ln(5.2);
$pdf->Cell(31);
$pdf->Cell(32, 0, $row2["CUIT"]);

Example #16
0
	/**
	 * Merges your provided PDFs and outputs to specified location.
	 * @param $outputmode
	 * @param $outputname
	 * @return PDF
	 */
	public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf')
	{
		if(!isset($this->_files) || !is_array($this->_files)): throw new exception("No PDFs to merge."); endif;
		
		$fpdi = new FPDI;
		
		//merger operations
		foreach($this->_files as $file)
		{
			$filename  = $file[0];
			$filepages = $file[1];
			
			$count = $fpdi->setSourceFile($filename);
			
			//add the pages
			if($filepages == 'all')
			{
				for($i=1; $i<=$count; $i++)
				{
					$template 	= $fpdi->importPage($i);
					$size 		= $fpdi->getTemplateSize($template);
					
					$fpdi->AddPage('P', array($size['w'], $size['h']));
					$fpdi->useTemplate($template);
				}
			}
			else
			{
				foreach($filepages as $page)
				{
					if(!$template = $fpdi->importPage($page)): throw new exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); endif;
					$size = $fpdi->getTemplateSize($template);
					
					$fpdi->AddPage('P', array($size['w'], $size['h']));
					$fpdi->useTemplate($template);
				}
			}	
		}
		
		//output operations
		$mode = $this->_switchmode($outputmode);
		
		if($mode == 'S')
		{
			return $fpdi->Output($outputpath, 'S');
		}
		else
		{
			if($fpdi->Output($outputpath, $mode)!==false)
			{
				return true;
			}
			else
			{
				throw new exception("Error outputting PDF to '$outputmode'.");
				return false;
			}
		}
		
		
	}
Example #17
0
 function showForm($data = "", $msg = "")
 {
     global $t, $db, $sesIdUsuario, $hoy, $usuario;
     $idReg = $data[idReg];
     $idPedido = $data[idPedido];
     //echo "ID_PEDIDO : $idPedido <hr>";
     $t->set_file("page", "opGuia.inc.html");
     // -----------------------------------------
     // Datos del Pedido
     // -----------------------------------------
     $sql = "select id_cliente,ori,des,mov,bkg,pos_fec,pos_hor,pos_min,ori,des, ";
     $sql .= "destinatario,destinatario_dom ";
     $sql .= "from PEDIDO where id_pedido='{$idPedido}' ";
     $db->query($sql);
     while ($db->next_record()) {
         $idCliente = $db->f(id_cliente);
         $cliente = getValueTable("cliente", "CLIENTE", "id_cliente", $idCliente);
         $ori = $db->f(ori);
         $des = $db->f(des);
         $mov = $db->f(mov);
         $bkg = $db->f(bkg);
         $posFec = $db->f(pos_fec);
         $posHor = $db->f(pos_hor);
         $posMin = $db->f(pos_min);
         $pos = "{$posFec} {$posHor}:{$posMin}";
         $ori = $db->f(ori);
         $des = $db->f(des);
         $ruta = "{$ori} / {$des}";
         $destinatario = $db->f(destinatario);
         $destinatarioDom = $db->f(destinatario_dom);
     }
     $t->set_var(array("ID_REG" => $idReg, "ID_PEDIDO" => $idPedido, "ACTION" => $PHP_SELF, "MENSAJE" => "", "CLIENTE" => $cliente, "ORI" => $ori, "DES" => $des, "MOV" => $mov, "CANCELADO_DETALLE" => "", "IMPRIMIR" => "<a href=\"javascript:ventanaNueva('opGuiaImp.php?idReg={$idReg}',850,600)\"><img src=\"../images/imp.png\" border=\"0\" height=\"30\" width=\"30\"></a>", "PDF" => ""));
     // Consultar si esta cancelada la Guia de embarque.
     $stRegGE = getValueTable("st_reg", "GUIA", "id_guia", $idReg);
     $bajaIdUsr = getValueTable("baja_id_usr", "GUIA", "id_guia", $idReg);
     $bajaFec = getValueTable("baja_fec", "GUIA", "id_guia", $idReg);
     if ($stRegGE == "B") {
         $bajaUsr = getValueTable("usuario", "USUARIO", "id_usuario", $bajaIdUsr);
         $bajaDetalle = "<font color=red>**CANCELADO**<br>Por: {$bajaUsr}<br>Fecha : {$bajaFec}</font>";
         $t->set_var("CANCELADO_DETALLE", "{$bajaDetalle}");
     } else {
         $stRegColor = "class=\"color3\"";
         $bajaDetalle = "";
         $t->set_var("BAJA", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','{$idGuia}','baja')\"><img src=\"../images/b_del.png\" border=0></a>");
     }
     if (empty($idReg) || $idReg == 0) {
         $op = "nuevo";
     } elseif ($stRegGE == "B") {
         $op = "cancelado";
         $t->set_var("GUARDAR", "");
         $t->set_var("ACTUALIZAR", "");
         $t->set_var("IMPRIMIR", "");
     } else {
         $op = "editar";
     }
     switch ($op) {
         case "editar":
             if ($usuario->havePerm("1,9", $_SESSION['sesArrPerms'])) {
                 // 9 : [Transporte] Captura Pedidos
                 $t->set_var("GUARDAR", "");
                 $t->set_var("ACTUALIZAR", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','{$idReg}','update')\">Actualizar Datos</a>");
             } else {
                 $t->set_var("GUARDAR", "");
                 $t->set_var("ACTUALIZAR", "");
             }
             break;
         case "nuevo":
             if ($usuario->havePerm("1,9", $_SESSION['sesArrPerms'])) {
                 if (!empty($idPedido)) {
                     $t->set_var("GUARDAR", "<a href=\"javascript:submitD(document.frm1,'{$PHP_SELF}','','rec')\">Guardar</a>");
                     $t->set_var("ACTUALIZAR", "");
                 } else {
                     $t->set_var("GUARDAR", "<font color=\"red\"><b>ERROR : PRIMERO SELECCIONE UN PEDIDO Y LUEGO CREE UNA GUIA DE EMBARQUE.</b></font>");
                     $t->set_var("ACTUALIZAR", "");
                 }
             } else {
                 $t->set_var("GUARDAR", "");
                 $t->set_var("ACTUALIZAR", "");
             }
             break;
     }
     // --------------------------
     // CONSULTA DE GUIA
     // --------------------------
     if ($idReg > 0) {
         $sql = "select * from GUIA where id_guia='{$idReg}'";
         $db->query($sql);
         while ($db->next_record()) {
             $serie = $db->f(serie);
             $folio = $db->f(folio);
             $data[folio] = $serie . $folio;
             //$data[facturaS] = $db->f(factura_s);
             $data[factura] = $db->f(factura);
             $idConte = $db->f(id_contenedor);
             $idEquipo = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte);
             $data[conte] = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte);
             $data[equipo] = getValueTable("equipo", "EQUIPO", "id_equipo", $idEquipo);
             $data[sello] = $db->f(sello);
             $data[flete] = $db->f(flete);
             $data[seguro] = $db->f(seguro);
             $data[otroCosto] = $db->f(otro_costo);
             $data[diceContener] = $db->f(dice_contener);
             $data[mercancia] = $db->f(mercancia);
             $data[bulto] = $db->f(bulto);
             $data[operador] = $db->f(operador);
             $data[nota] = $db->f(nota);
             $data[traUni] = $db->f(tra_uni);
             $data[traPla] = $db->f(tra_pla);
             $data[chaUni] = $db->f(cha_uni);
             $data[chaPla] = $db->f(cha_pla);
             $data[terLlega] = $db->f(ter_llega);
             $data[terSale] = $db->f(ter_sale);
             $data[terVacLlega] = $db->f(ter_vac_llega);
             $data[terVacSale] = $db->f(ter_vac_sale);
             $data[referencia] = $db->f(referencia);
             $data[tonelaje] = $db->f(tonelaje);
             $data[valorDec] = $db->f(valor_dec);
             $capIdUsr = $db->f(cap_id_usr);
             $capFec = $db->f(cap_fec);
             $modIdUsr = $db->f(mod_id_usr);
             $modFec = $db->f(mod_fec);
             $capUsr = getValueTable("usuario", "USUARIO", "id_usuario", $capIdUsr);
             $modUsr = getValueTable("usuario", "USUARIO", "id_usuario", $modIdUsr);
             $data[maniobra] = $db->f(maniobra);
             $data[autopista] = $db->f(autopista);
             $data[clase] = $db->f(clase);
             $data[ruta] = $db->f(ruta);
             $data[gastosViaje] = $db->f(gastos_viaje);
             $data[dollyNum] = $db->f(dolly_num);
             $data[dollyPla] = $db->f(dolly_pla);
         }
     }
     // Combos
     if ($data[maniobra] == "M") {
         $t->set_var("MANI_SEL_M", "selected");
     }
     if ($data[maniobra] == "C") {
         $t->set_var("MANI_SEL_C", "selected");
     }
     if ($data[autopista] == "S") {
         $t->set_var("AUTOPISTA_SEL_S", "selected");
     }
     if ($data[autopista] == "N") {
         $t->set_var("AUTOPISTA_SEL_N", "selected");
     }
     // Combo Bulto
     if ($data[bulto] == "20-DC") {
         $t->set_var("20DCSEL", "selected");
     }
     if ($data[bulto] == "40-DC") {
         $t->set_var("40DCSEL", "selected");
     }
     if ($data[bulto] == "40-HC") {
         $t->set_var("40HCSEL", "selected");
     }
     if ($data[bulto] == "20-RF") {
         $t->set_var("20RFSEL", "selected");
     }
     if ($data[bulto] == "40-RF") {
         $t->set_var("40RFSEL", "selected");
     }
     if ($data[bulto] == "20-OT") {
         $t->set_var("20OTSEL", "selected");
     }
     if ($data[bulto] == "40-OT") {
         $t->set_var("40OTSEL", "selected");
     }
     if ($data[bulto] == "20-FL") {
         $t->set_var("20FLSEL", "selected");
     }
     if ($data[bulto] == "40-FL") {
         $t->set_var("40FLSEL", "selected");
     }
     if ($data[bulto] == "20-TK") {
         $t->set_var("20TKSEL", "selected");
     }
     if ($data[bulto] == "40-TK") {
         $t->set_var("40TKSEL", "selected");
     }
     // Combo Clase de contenedor
     if ($data[clase] == "A") {
         $t->set_var("CLASESELA", "selected");
     }
     if ($data[clase] == "B") {
         $t->set_var("CLASESELB", "selected");
     }
     if ($data[clase] == "C") {
         $t->set_var("CLASESELC", "selected");
     }
     if ($data[clase] == "D") {
         $t->set_var("CLASESELD", "selected");
     }
     if ($data[clase] == "FG") {
         $t->set_var("CLASESELFG", "selected");
     }
     if ($data[clase] == "GC") {
         $t->set_var("CLASESELGC", "selected");
     }
     $folioX = $data[folio];
     $t->set_var(array("FOLIO" => $folioX, "FACTURA_S" => $data[facturaS], "FACTURA" => $data[factura], "REFERENCIA" => $data[referencia], "TONELAJE" => $data[tonelaje], "VALOR_DEC" => $data[valorDec], "CONTENEDOR" => $data[conte], "EQUIPO" => $data[equipo], "SELLO" => $data[sello], "FLETE" => $data[flete], "MANIOBRA" => $data[maniobra], "SEGURO" => $data[seguro], "AUTOPISTA" => $data[autopista], "OTRO_COSTO" => $data[otroCosto], "MERCANCIA" => $data[mercancia], "DICE_CONTENER" => $data[diceContener], "OPERADOR" => $data[operador], "NOTA" => $data[nota], "TRA_UNI" => $data[traUni], "TRA_PLA" => $data[traPla], "CHA_UNI" => $data[chaUni], "CHA_PLA" => $data[chaPla], "TER_LLEGA" => $data[terLlega], "TER_SALE" => $data[terSale], "TER_VAC_LLEGA" => $data[terVacLlega], "TER_VAC_SALE" => $data[terVacSale], "CAPTURO" => "{$capUsr} / {$capFec}", "MODIFICO" => "{$modUsr} / {$modFec}", "RUTA" => $data[ruta], "GASTOS_VIAJE" => $data[gastosViaje], "DOLLY_NUM" => $data[dollyNum], "DOLLY_PLA" => $data[dollyPla]));
     // ""=>$data[],
     //$facS = $data[facturaS];
     $facX = $data[factura];
     if (preg_match("/(.{0,2})(.*)/", $facX, $parts)) {
         $facS = $parts[1];
         $facN = $parts[2];
     }
     if ($idReg > 0 && !empty($facN)) {
         // ----------------------------------------------
         // PROCESO DE EDICION DE FACTURA-PDF
         //
         // 1. Comprobar que exista la factura original.
         // 2. Buscar todas las GE que tengan la misma factura relacionada.
         // 3. Consultar (Folio_serie,Folio,Contenedor,Tipo,Bkg,Posicionamiento,Ruta,etc.
         // 4. Generar nuevo PDF.
         // ----------------------------------------------
         $facN2 = str_pad($facN, 7, 0, STR_PAD_LEFT);
         $filePdfOri = "OPE0606129RAF" . $facS . $facN2 . ".pdf";
         $filePdfEdi = "OPE0606129RAF" . $facS . $facN2 . "_.pdf";
         // Consultar datos GE con la misma Factura.
         unset($txtFac);
         unset($txtFac2);
         $numConte = 0;
         $sql = "select folio,id_contenedor ";
         $sql .= "from GUIA ";
         //$sql.="where factura_s='$facS' and factura='$facN' and st_reg<>'B' ";
         $sql .= "where factura='{$facX}' and st_reg<>'B' ";
         $db->query($sql);
         while ($db->next_record()) {
             $numConte++;
             $folioX = $db->f(folio);
             $folioS = substr($folioX, 0, 2);
             $folioN = substr($folioX, 2, 10);
             $idConte = $db->f(id_contenedor);
             $conte = getValueTable("numero", "CONTENEDOR", "id_contenedor", $idConte);
             $idEq = getValueTable("id_equipo", "CONTENEDOR", "id_contenedor", $idConte);
             $equipo = getValueTable("equipo", "EQUIPO", "id_equipo", $idEq);
             // Si la cantidad de contenedores es mayor al limite, entonces 2do arreglo.
             $maxConte = 17;
             if ($numConte > $maxConte) {
                 $txtFac2[] = "{$folioS} {$folioN} {$conte} {$equipo}";
             } else {
                 $txtFac[] = "{$folioS} {$folioN} {$conte} {$equipo}";
             }
         }
         // ---------------------------------------------------
         // Editar factura.
         if (file_exists("../facturas/{$filePdfOri}")) {
             //$pdf =& new FPDI();
             $pdf = new FPDI();
             $pdf->AddPage();
             //Set the source PDF file
             $pagecount = $pdf->setSourceFile("../facturas/{$filePdfOri}");
             //Import the first page of the file
             $tpl = $pdf->importPage(1);
             //Use this page as template
             $pdf->useTemplate($tpl);
             $pdf->SetFont('Arial', '', 7);
             // PAGINA #1
             // Inicializa la posición
             $destinatarioDom = str_replace("\n", "", $destinatarioDom);
             $destinatarioDom = str_replace("\r", "", $destinatarioDom);
             $pdf->SetXY(60, 90);
             $pdf->Cell(45, 5, "BKG : {$bkg} ", 0, 0, 'L');
             $pdf->SetXY(60, 93);
             $pdf->Cell(45, 5, "POSICIONAMIENTO : {$pos} ", 0, 0, 'L');
             $pdf->SetXY(60, 96);
             $pdf->Cell(45, 5, "RUTA : {$ruta}", 0, 0, 'L');
             $pdf->SetXY(60, 99);
             $pdf->Cell(45, 5, "SALIDA DE VACIO : ? ", 0, 0, 'L');
             $pdf->SetXY(60, 105);
             $pdf->Cell(60, 5, $destinatario, 0, 0, 'L');
             // Seccionar a varias Cell, el domicilio del destinatario
             // Direccion de destinatario
             $s = $destinatarioDom;
             $s = strtoupper($s);
             $lenTl = strlen($s);
             // Conocer el numero de lineas
             $nlDes = $lenTl / 15;
             // El total de caracteres entre el ancho de 35 que es el max de caracteres x linea.
             $posIni = 0;
             $y = 109;
             for ($i = 1; $i <= $nlDes; $i++) {
                 $txtX = substr($s, $posIni, 35);
                 $pdf->SetXY(60, $y);
                 $pdf->Cell(60, 4, $txtX, 0, 0, 'L');
                 $posIni = $posIni + 35;
                 $y = $y + 3;
             }
             // ---------------------------
             $y = 90;
             foreach ($txtFac as $txt) {
                 $pdf->SetXY(10, $y);
                 $pdf->Cell(45, 5, $txt, 0, 0, 'L');
                 $y = $y + 3;
             }
             if ($numConte > $maxConte) {
                 $pdf->SetXY(60, 130);
                 $pdf->Cell(45, 5, "*** VER ANEXO *** VER ANEXO ***", 0, 0, 'L');
                 // PAGINA #2
                 $pdf->AddPage();
                 $y = 20;
                 foreach ($txtFac2 as $txt2) {
                     $pdf->SetXY(10, $y);
                     $pdf->Cell(45, 5, "{$txt2}", 0, 0, 'L');
                     $y = $y + 3;
                     if ($y == 266) {
                         $y = 20;
                         $pdf->AddPage();
                     }
                 }
             }
             // Grabar archivo
             //echo "[$filePdfEdi]";
             $pdf->Output("../facturas/{$filePdfEdi}", "F");
             //$x  = file_exists("../facturas/$filePdfEdi");
             if (file_exists("../facturas/{$filePdfEdi}")) {
                 $pdfImg = "<a href=\"javascript:ventanaNueva('../facturas/{$filePdfEdi}',800,600)\"><img src=\"../images/pdf.gif\" width=\"25\" hight=\"20\" border=0></a>";
             } else {
                 $pdfImg = "";
             }
             $t->set_var("PDF", "{$pdfImg}");
         } else {
             $t->set_var("PDF", "");
         }
     }
     // -----------------------------------------------
     //  Control de mensajes
     // -------------------------------------------
     if (!empty($msg)) {
         $canMsg = count($msg);
         if ($canMsg > 0) {
             foreach ($msg as $val) {
                 $cadMsg .= $val . " <br>";
             }
             $t->set_var(array("MENSAJE" => $cadMsg));
         }
     }
     $t->pparse("out", "page");
 }
Example #18
0
 public function save_design()
 {
     if ($this->input->post('mode') == 'edit') {
         $this->db->delete('designs', array('id' => $this->input->post('design_id')));
     }
     $faceMacket = str_replace('http://klever.media/', '', $this->input->post('faceMacket'));
     $backMacket = str_replace('http://klever.media/', '', $this->input->post('backMacket'));
     $face = $this->input->post('face');
     $back = $this->input->post('back');
     // get all fonts
     $query = $this->db->get('fonts');
     $fonts = array();
     foreach ($query->result() as $font) {
         $fonts[$font->family] = $font->source;
     }
     // generate pdf face template name and preview name
     $face_pdf = 'uploads/redactor/face_' . md5(microtime(true)) . '.pdf';
     $face_preview = 'uploads/redactor/face_' . md5(microtime(true)) . '.jpg';
     // convert face image to pdf
     $img = new Imagick($faceMacket);
     $img->setresolution(300, 300);
     $img->setcolorspace(Imagick::COLORSPACE_CMYK);
     $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
     $img->setimageformat('pdf');
     $img->writeimage($face_pdf);
     // include TCPDF ana FPDI
     include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
     include_once APPPATH . 'libraries/tcpdf/fpdi.php';
     include_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php';
     $fontMaker = new TCPDF_FONTS();
     // создаём лист
     $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
     $pdf->SetMargins(0, 0, 0, true);
     $pdf->AddPage('L');
     // загрузим ранее сохранённый шаблон
     $pdf->setSourceFile($face_pdf);
     $pdf->SetMargins(0, 0, 0, true);
     $tplIdx = $pdf->importPage(1);
     $pdf->useTemplate($tplIdx, null, null, 0, 0, true);
     // установим опции для pdf
     $pdf->setCellHeightRatio(1);
     $pdf->setCellPaddings(0, 0, 0, 0);
     $pdf->setCellMargins(0, 0, 0, 0);
     $pdf->SetAutoPageBreak(false, 0);
     $pdf->SetPrintHeader(false);
     $pdf->SetPrintFooter(false);
     if (!empty($face)) {
         // отрисуем сначала изображения лица
         foreach ($face as $item) {
             if ($item['type'] == 'image') {
                 $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
             }
         }
         // потом текст на лице
         foreach ($face as $item) {
             if ($item['type'] == 'text') {
                 $cmyk = $this->rgbToCmyk($item['color']);
                 $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
                 // set font
                 $tcpdfFont = $fontMaker->addTTFfont(realpath('fonts/redactor/' . $fonts[$item['font']]));
                 $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
                 $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
             }
         }
     }
     // сохраним пдф лица
     $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf, 'F');
     // сделаем превью для пользователя
     $im = new Imagick();
     $im->setResolution(300, 300);
     $im->readimage($face_pdf . '[0]');
     $im->flattenimages();
     $im->setImageFormat('jpg');
     $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
     $im->writeImage($face_preview);
     $im->clear();
     $im->destroy();
     //exec('$ convert ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf . ' ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_preview);
     // есть ли оборот
     if (!empty($backMacket)) {
         // generate pdf back template name and preview name
         $back_pdf = 'uploads/redactor/back_' . md5(microtime(true)) . '.pdf';
         $back_preview = 'uploads/redactor/back_' . md5(microtime(true)) . '.jpg';
         // convert back image to pdf
         $img = new Imagick($backMacket);
         $img->setresolution(300, 300);
         $img->setcolorspace(Imagick::COLORSPACE_CMYK);
         $img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
         $img->setimageformat('pdf');
         $img->writeimage($back_pdf);
         // создаём лист
         $pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
         $pdf->AddPage('L');
         // загрузим ранее сохранённый шаблон
         $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf);
         $pdf->SetMargins(0, 0, 0, true);
         $tplIdx = $pdf->importPage(1);
         $pdf->useTemplate($tplIdx, null, null, 0, 0, true);
         // установим опции для pdf
         $pdf->SetMargins(0, 0, 0, true);
         $pdf->setCellHeightRatio(1);
         $pdf->setCellPaddings(0, 0, 0, 0);
         $pdf->setCellMargins(1, 1, 1, 1);
         $pdf->SetAutoPageBreak(false);
         $pdf->SetPrintHeader(false);
         $pdf->SetPrintFooter(false);
         if (!empty($back)) {
             // отрисуем сначала изображения оборота
             foreach ($back as $item) {
                 if ($item['type'] == 'image') {
                     $pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
                 }
             }
             // потом текст на обороте
             foreach ($back as $item) {
                 if ($item['type'] == 'text') {
                     $cmyk = $this->rgbToCmyk($item['color']);
                     $pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
                     // set font
                     $tcpdfFont = $fontMaker->addTTFfont($_SERVER['DOCUMENT_ROOT'] . '/fonts/redactor/' . $fonts[$item['font']]);
                     $pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
                     $pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
                 }
             }
         }
         // сохраним пдф оборота
         $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf, 'F');
         // сделаем превью для пользователя
         $im = new Imagick();
         $im->setResolution(300, 300);
         $im->readimage($back_pdf . '[0]');
         $im->setImageFormat('jpg');
         $im->flattenimages();
         $im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
         $im->writeImage($back_preview);
         $im->clear();
         $im->destroy();
     }
     $this->db->insert('products', array('name' => 'cards_pvc', 'tiraj' => 100, 'weight' => 0.5, 'price' => 0.49, 'cost' => 49, 'macket' => 'my_macket'));
     $product_id = $this->db->insert_id();
     $this->db->insert('designs', array('product_id' => $product_id, 'theme_id' => $this->input->post('theme'), 'face_background' => $faceMacket, 'back_background' => empty($backMacket) ? NULL : $backMacket, 'face' => $face_preview, 'back' => empty($back_preview) ? '' : $back_preview, 'type' => 'system'));
     $design_id = $this->db->insert_id();
     $options = array();
     if (!empty($face)) {
         foreach ($face as $item) {
             if ($item['type'] == 'text') {
                 $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']);
             } else {
                 $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'face', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL);
             }
         }
     }
     if (!empty($back)) {
         foreach ($back as $item) {
             if ($item['type'] == 'text') {
                 $options[] = array('design_id' => $design_id, 'type' => 'text', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => NULL, 'height' => NULL, 'content' => $item['content'], 'font' => $item['font'], 'color' => $item['color'], 'size' => $item['size']);
             } else {
                 $options[] = array('design_id' => $design_id, 'type' => 'image', 'front' => 'back', 'top' => $item['top'], 'left' => $item['left'], 'width' => $item['width'], 'height' => $item['height'], 'content' => $item['content'], 'font' => NULL, 'color' => NULL, 'size' => NULL);
             }
         }
     }
     if (count($options) > 0) {
         $this->db->insert_batch('design_options', $options);
     }
     echo 'OK';
 }
<?php

header('Content-Type: text/html; charset=utf-8');
require_once '../modelo/utilidades/Fpdf/fpdf.php';
require_once '../modelo/utilidades/Fpdi/fpdi.php';
//Get the base-64 string from data
$filteredData = substr($_POST['img_val'], strpos($_POST['img_val'], ",") + 1);
//Decode the string
$unencodedData = base64_decode($filteredData);
//Save the image
file_put_contents('img.png', $unencodedData);
//Show the image
//echo '<img src="'.$_POST['img_val'].'" />';
$pdf = new FPDI();
$pdf->setSourceFile('TemplateReporte.pdf');
// seteamos la fuente, el estilo y el tamano
$pdf->SetFont('Times', 'B', 10);
// seteamos la posicion inicial
$pdf->SetXY(25, 80);
date_default_timezone_set('America/Bogota');
setlocale(LC_ALL, "es_ES");
$dias = array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado");
$meses = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
//agregamos una pagina
$pdf->AddPage();
$pdf->SetFont('Arial');
// seleccionamos la primera pagina del docuemnto importado
$tplIdx = $pdf->importPage(1);
// usamos la pagina importado como template
$pdf->useTemplate($tplIdx);
//seteamos la posicion X
Example #20
0
	public function view_sign_oc(){
		require_once('./assets/fpdf17/fpdf.php');
		require_once('./assets/fpdf17/fpdi.php');
		$oc_id=$this->uri->segment(3,'');
		
		// init pce data                       
		$oc_dat=$this->m_oc->get_oc_by_id($oc_id);
		$project=$this->m_project->get_project_by_id($oc_dat->project_id);
        //init sign pic
        $ae_sign_user_dat=$this->m_user->get_user_by_login_name($project->project_cs);
        $ae_sign_filename="no";
        if (isset($ae_sign_user_dat->sign_filename)) {
          $ae_sign_filename=$ae_sign_user_dat->sign_filename;
        }
        $finance_sign_dat=$this->m_user->get_user_by_login_name($oc_dat->fc_sign);
        $finance_sign_filename="no";
        if (isset($finance_sign_dat->sign_filename)) {
          $finance_sign_filename=$finance_sign_dat->sign_filename;
        }
        // initiate FPDI
        $pdf = new FPDI();

        // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวธรรมดา กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','','angsa.php');
             
            // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','B','angsab.php');
             
            // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','I','angsai.php');
             
            // เพิ่มฟอนต์ภาษาไทยเข้ามา ตัวหนา  กำหนด ชื่อ เป็น angsana
            $pdf->AddFont('angsana','BI','angsaz.php');


        // get the page count
        $pageCount = $pdf->setSourceFile("./media/real_pdf/".$oc_dat->filename);
        // iterate through all pages
        for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
            // import a page
            $templateId = $pdf->importPage($pageNo);
            // get the size of the imported page
            $size = $pdf->getTemplateSize($templateId);

            // create a page (landscape or portrait depending on the imported page size)
            if ($size['w'] > $size['h']) {
                $pdf->AddPage('L', array($size['w'], $size['h']));
            } else {
                $pdf->AddPage('P', array($size['w'], $size['h']));
            }

            // use the imported page
            $pdf->useTemplate($templateId);

            $pdf->SetTextColor(0,0,0);
            $pdf->SetFont('angsana','B',14);
            $pdf->SetXY(5, 5);
            //$pdf->Write(8, 'A complete document imported with FPDI');

            //// temporaly disable 
            if ($finance_sign_filename!="no"&&$finance_sign_filename!=""&&$finance_sign_filename!=null) {
              //$pdf->Image("./media/sign_photo/".$finance_sign_filename,100,10,40,0);
            }
            if ($ae_sign_filename!="no"&&$ae_sign_filename!=""&&$ae_sign_filename!=null) {
              //$pdf->Image("./media/sign_photo/".$ae_sign_filename,100,110,40,0);
            }
            //$pdf->Image("images/play.png",100,100,100,0);
        }
        $new_filename=$oc_dat->oc_no."_A.pdf";

        // Output the new PDF
        //@unlink("./media/real_pdf/".$new_filename);
        $pdf->Output($new_filename,"I");
        //redirect("media/real_pdf/".$new_filename);
	}
Example #21
0
<?php

//This program creates a new pdf using a blank pdf template of the clinic's new patient form, and then pulls the user's information from the database, and overlays it on the form in the correct spaces.
include '/home1/columch7/public_html/columbiaphysicaltherapyinc/form2/config.php';
//include '/var/www/html/form2/config.php';
require_once $fpdf;
require_once $fpdi;
// initiate FPDI
$pdf = new FPDI();
// get the page count
$pageCount = $pdf->setSourceFile('New-Patient-info-moseslake.pdf');
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
    // import a page
    $templateId = $pdf->importPage($pageNo);
    // get the size of the imported page
    $size = $pdf->getTemplateSize($templateId);
    // create a page (landscape or portrait depending on the imported page size)
    if ($size['w'] > $size['h']) {
        $pdf->AddPage('L', array($size['w'], $size['h']));
    } else {
        $pdf->AddPage('P', array($size['w'], $size['h']));
    }
    // use the imported page
    $pdf->useTemplate($templateId);
    $pdf->SetAutoPageBreak(false);
    //Calls the database
    $db = new SQLite3($columbiaDB);
    //obtains ID and AUTH numbers from the link
    $ID = $_GET["ID"];
    $AUTH = $_GET["AUTH"];
							 AND ar_tipo = ta_id
							 AND da_idtipodocumento = td_id
							 AND da_secuenciatrazabil = :SECUENCIATRAZABIL ";
			
			$params = array(":SECUENCIATRAZABIL" => $SECUENCIATRAZABIL );				 
			$stmt = DBExecSql($conn, $sql, $params);
			$rowCabecera3 = DBGetQuery($stmt, 1, false);	
			
			$params = array(":op" => $_REQUEST["op"] );				 
			$CODBARRASCLAVE = valorSql("SELECT ARCHIVO.GET_CODBARRASCLAVE('OPT', :op ,'','','') FROM DUAL", "", $params);

//-------------------------------------------------------------------------------------------- 
//--------------------------------------------------------------------------------------------
		
		$pdf = new FPDI();
		$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/varios/tesoreria/templates/reporte_reemplazo.pdf");


		$pdf->AddPage();
		$tplIdx = $pdf->importPage(1);
		$pdf->SetAuthor('ART');
		$pdf->useTemplate($tplIdx);

		// Dibujo la cabecera..
		$pdf->SetFont("Arial", "", 16);
		$pdf->Text(75, 15, $rowCabecera["OP"]);

		$pdf->SetFont("Arial", "", 11);
		$pdf->Text(40, 21, $rowCabecera["BENEFICIARIO"]);

		$pdf->SetFont("Arial", "", 7);
$idFormulario = valorSql($sql, "", $params);

$params = array(":idformulario" => $idFormulario);
$sql =
	"SELECT art.utiles.armar_cuit(sa_cuit) cuit, sa_nombre
		 FROM asa_solicitudafiliacion
		WHERE sa_idformulario = :idformulario";
$stmt = DBExecSql($conn, $sql, $params);
$row2 = DBGetQuery($stmt, 1, false);

if ($autoPrint)
	$pdf = new PDF_AutoPrint();
else
	$pdf = new FPDI();

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/nomina_personal_expuesto.pdf");

$pdf->AddPage("L");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
$pdf->SetFont("Arial", "B", 9);

$pdf->Ln(17);
$pdf->Cell(14);
$pdf->Cell(226, 0, $row2["SA_NOMBRE"]);

$pdf->Cell(16);
$pdf->Cell(0, 0, $row2["CUIT"]);


if ($autoPrint)
		// INICIO - Generación de gráfico que va incrustado en el reporte..
		try {
			$_REQUEST["actual"] = $row["PRIMAANUALCOMPSINFORMATO"];
			$_REQUEST["archivo"] = "W_".$_SESSION["usuario"]."_".date("YmdHis").".png";
			$_REQUEST["provart"] = $row["PRIMAANUALSINFORMATO"];

			require_once($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_cotizacion/generar_grafico_comparativo.php");
			$graficoOk = true;
		}
		catch (Exception $e) {
			$graficoOk = false;
		}
		// FIN - Generación de gráfico que va incrustado en el reporte..

if ($graficoOk) {
		$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_cotizacion/plantillas/analisis_comparativo_costos.pdf");
		$pdf->SetDrawColor(255, 255, 255);
		$pdf->SetFillColor(255, 255, 255);

		$pdf->AddPage();
		$tplIdx = $pdf->importPage(1);
		$pdf->useTemplate($tplIdx);
		$pdf->SetFont("Arial", "B", 10);

		$pdf->Ln(33);
		$pdf->Cell(40);
		$pdf->Cell(144, 0, $row["RAZONSOCIAL"]);

		$pdf->Ln(6.6);
		$pdf->Cell(28);
		$pdf->Cell(36, 0, $row["CUIT"]);
					se_nroestableci || ' - ' || se_nombre nroestablecimiento,
					pv_descripcion provincia,
					se_telefonos telefonos
		 FROM afi.ase_solicitudestablecimiento, comunes.cac_actividad ciiu, art.cpv_provincias
		WHERE se_idactividad = ciiu.ac_id
			AND se_provincia = pv_codigo
			AND se_id = :idsolicitudestablecimiento";
$stmt = DBExecSql($conn, $sql, $params);
$rowE = DBGetQuery($stmt, 1, false);

if ($autoPrint)
	$pdf = new PDF_AutoPrint();
else
	$pdf = new FPDI();

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/exposicion_riesgos_quimicos.pdf");

$pdf->AddPage("L");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
$pdf->SetFont("Arial", "B", 9);

$pdf->Ln(22);
$pdf->Cell(16);
$pdf->Cell(252, 0, $row2["SA_NOMBRE"]);

$pdf->Cell(20);
$pdf->Cell(0, 0, $row2["CUIT"]);

$pdf->Ln(8);
$pdf->Cell(44);
	$params = array(":nrosolicitud" => $numeroSolicitud);
	$sql = "BEGIN art.cotizacion.get_valor_carta(:nrosolicitud, :data); END;";
	$stmt = DBExecSP($conn, $curs, $sql, $params);
	$rowValorFinal = DBGetSP($curs, false);

	$cuotaInicial = $rowValorFinal["COSTOMENSUAL"];
	$porcentajeVariable = $rowValorFinal["PORCVARIABLE"];
	$sumaFija = $rowValorFinal["SUMAFIJA"];
}

if ($autoPrint)
	$pdf = new PDF_AutoPrint();
else
	$pdf = new FPDI();

$pdf->setSourceFile($_SERVER["DOCUMENT_ROOT"]."/modules/solicitud_afiliacion/templates/solicitud_afiliacion.pdf");

//Página 1..
$pdf->AddPage();
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->SetFont("Arial", "", 8);

if (($row2["SA_MOTIVOALTA"] == "03") or ($row2["SA_MOTIVOALTA"] == "04") or ($row2["SA_MOTIVOALTA"] == "05")) {
	$pdf->Ln(6);
	$pdf->Cell(-0.4);
	$pdf->Cell(0, 0, "X");

	$pdf->Ln(8.2);
	$pdf->Cell(1);
}
    if (mysql_num_rows($sql) == 1) {
        $row = mysql_fetch_assoc($sql);
    } else {
        print "<meta http-equiv=\"Refresh\" content=\"0;URL=MainPage.php\">";
        exit;
    }
}
if ($_SESSION['status'] == "admin") {
    $query = "SELECT * FROM `abiturients` WHERE `ab_id` = '" . $id . "'";
    $sql = mysql_query($query) or die(mysql_error());
    if (mysql_num_rows($sql) == 1) {
        $row = mysql_fetch_assoc($sql);
    }
}
$pdf = new FPDI();
$pageCount = $pdf->setSourceFile("img/ugoda2014.pdf");
$pageNo = 1;
$templateId = $pdf->importPage($pageNo);
$size = $pdf->getTemplateSize($templateId);
$pdf->AddPage('P', array($size['w'], $size['h']));
$pdf->useTemplate($templateId);
$pdf->AddFont('Times', '', 'times.php');
$pdf->SetFont('Times', '', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFontSize(11);
$pdf->SetXY(35, 61);
$pdf->Write(5, $row['lastname'] . " " . $row['firstname'] . " " . $row['patronymic']);
$pdf->SetXY(55, 70);
if ($row['type'] == "mag") {
    $pdf->Write(5, "6-й курс, " . $row['faculty']);
}
Example #28
0
         }
         if (in_array($cfile->name, $fnames)) {
             continue;
         }
         $docs[] = $doc['name'] . ':::' . $cfile->size;
         // нужно переделать на хеш файла
         $fnames[] = $cfile->name;
         $p = pathinfo($cfile->name);
         if (strtolower($p['extension']) != 'pdf') {
             $save = false;
             break;
         }
         ++$count_docs;
         $tmp_name = '/tmp/' . uniqid() . '.pdf';
         file_put_contents($tmp_name, file_get_contents(WDCPREFIX . '/' . $cfile->path . $cfile->name));
         $pagecount = $pdf->setSourceFile($tmp_name);
         $tplidx = $pdf->importPage($pagecount, '/MediaBox');
         if (preg_match('/^Счет-фактура/', $doc['name'])) {
             $pdf->addPage('L');
         } else {
             $pdf->addPage('P');
         }
         $pdf->useTemplate($tplidx, 0, 0);
         if ($doc['type'] == '20480') {
             $pagecount = $pdf->setSourceFile($tmp_name);
             $tplidx = $pdf->importPage($pagecount, '/MediaBox');
             $pdf->addPage('P');
             $pdf->useTemplate($tplidx, 0, 0);
         }
     }
 }
Example #29
-1
 public function generateCoupon($coupon_image_url, $user_id, $email_id)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/application/libraries/fpdf/fpdf.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/application/libraries/fpdf/fpdi.php';
     $pdf = new FPDI();
     $pageCount = $pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . "/application/libraries/coupon.pdf");
     $tplIdx = $pdf->importPage(1, '/MediaBox');
     $count = 0;
     $y = 145.5;
     $i = 1;
     $amt = 0;
     $pdf->addPage();
     $pdf->useTemplate($tplIdx, 3, 3, 210, 300);
     $pdf->SetFont('Arial', '', '9');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->Text(50, 80, 'User ID :');
     $pdf->Text(100, 80, $user_id);
     $pdf->Text(50, 90, 'Email ID :');
     $pdf->Text(100, 90, $email_id);
     $pdf->Image($coupon_image_url, 50, 100);
     $save_status = 1;
     if (!$save_status) {
         $pdf->Output();
     } else {
         $pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/images/coupons/' . 'coupon_' . $user_id . '.pdf', 'F');
     }
 }
Example #30
-2
 function page4($employee_id)
 {
     $this->load->helper('settings');
     $this->load->library('fpdf');
     //define('FPDF_FONTPATH',$this->config->item('fonts_path'));
     $this->load->library('fpdi');
     //print_r($personal_info);
     // initiate FPDI
     $pdf = new FPDI('P', 'mm', 'Legal');
     // add a page
     $pdf->AddPage();
     // set the sourcefile
     $pdf->setSourceFile('dtr/template/pds/page4.pdf');
     // import page 1
     $tplIdx = $pdf->importPage(1);
     // use the imported page and place it at point 10,10 with a width of 100 mm
     $pdf->useTemplate($tplIdx, 1, 1, 210);
     // now write some text above the imported page
     $pdf->SetFont('Arial');
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(8, 14);
     $q = new Question();
     $q->order_by('question_no');
     $questions = $q->get_by_employee_id($employee_id);
     foreach ($questions as $question) {
         if ($question->question_no == 1) {
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 2) {
             $pdf->Ln(21);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 3) {
             $pdf->Ln(26);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 4) {
             $pdf->Ln(21);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 5) {
             $pdf->Ln(26);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 6) {
             $pdf->Ln(26);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 7) {
             $pdf->Ln(21);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 8) {
             $pdf->Ln(35);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 9) {
             $pdf->Ln(12);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
         if ($question->question_no == 10) {
             $pdf->Ln(13);
             if ($question->answer == 1) {
                 $setx = 138.5;
             } else {
                 $setx = 164;
             }
             $pdf->SetX($setx);
             $pdf->Write(0, 'X');
         }
     }
     $pdf->SetXY(8, 233);
     //$pdf->Write(0, 'X');
     $r = new Reference();
     $references = $r->get_by_employee_id($employee_id);
     foreach ($references as $reference) {
         $pdf->SetX(8);
         $pdf->Write(0, $reference->name);
         $pdf->SetX(72);
         $pdf->Write(0, $reference->address);
         $pdf->SetX(134);
         $pdf->Write(0, $reference->tel_no);
         $pdf->Ln(4);
     }
     // CTC NO
     $pdf->SetXY(15, 275);
     $pdf->Write(0, $reference->ctc_no);
     $pdf->Ln(13);
     $pdf->SetX(15);
     $pdf->Write(0, $reference->issue_at);
     $pdf->Ln(13);
     $pdf->SetX(15);
     $pdf->Write(0, $reference->issue_on);
     $pdf->SetX(90);
     $pdf->Write(0, date('F d, Y'));
     // Output
     $pdf->Output('dtr/template/pds/page4_' . $employee_id . '.pdf', 'F');
     //header("location:".base_url()."resources/pdfs/archives/page4_".$employee_id.'.pdf');
     $this->pds[] = 'dtr/template/pds/page4_' . $employee_id . '.pdf';
 }