/**
  * @todo Realizar verificação de permissão e parametrizar
  */
 public function getPDF()
 {
     include_once 'fpdf/fpdf.php';
     include_once 'pdfbookmark/PDF_Bookmark.php';
     $allExists = true;
     $tiffs = '';
     foreach ($this->_rowset as $page) {
         $absoluteFilename = $this->_cachePath . $page['MD5'] . '.png';
         if (!file_exists($absoluteFilename)) {
             $allExists = false;
         }
         //Forma lista de TIFFs para conversão em multipágina, caso seja necessário
         $tiffs .= sprintf('%s.tif,0 ', $this->_uploadPath . $page['MD5']);
     }
     $pdfData = null;
     if ($allExists) {
         $allow = \AclFactory::checaPermissao(\Controlador::getInstance()->acl, \Controlador::getInstance()->usuario, \DaoRecurso::getRecursoById(999));
         $pdf = new \PDF_Bookmark();
         $pdf->SetMargins(0, 0, 0);
         $pdf->SetFont('Arial', '', 12);
         foreach ($this->_rowset as $key => $page) {
             if (!$allow && $page['FLG_PUBLICO'] == 0) {
                 continue;
             }
             $pdf->author = utf8_decode(__CABECALHO_ORGAO__);
             $pdf->title = 'Sistema Gerenciador de Documentos - v' . __VERSAO__;
             $pdf->creator = $pdf->title . ' (' . utf8_decode(\Controlador::getInstance()->usuario->NOME) . ')';
             $imagePath = $this->_cachePath . $page['MD5'] . '.png';
             if (!is_file($imagePath)) {
                 $imagePath = 'imagens/imagem_quebrada_a4.jpg';
             }
             if ($page["IMG_WIDTH"] < $page["IMG_HEIGHT"]) {
                 $pdf->AddPage("P", "A4");
                 $pdf->Image($imagePath, 0, 0, 210, 297, "PNG");
             } else {
                 $pdf->AddPage("L", "A4");
                 $pdf->Image($imagePath, 0, 0, 297, 210, "PNG");
             }
             $pdf->Bookmark('Pág. ' . $key + 1);
         }
         $pdfData = $pdf->Output("", 'S');
     } else {
         //Realiza estratégia de gerar TIFF multipágina e utilizar chamada ao sistema para gerar o PDF
         $absoluteFilename = $this->_cachePath . $page['MD5'];
         $absoluteTIFFFilename = $absoluteFilename . '.tif';
         $absolutePDFFilename = $absoluteFilename . '.pdf';
         //            shell_exec("tiffcp -c lzw -t {$tiffs} {$absoluteTIFFFilename}");//Dá erros para TIFFs específicos
         shell_exec("tiffcp {$tiffs} {$absoluteTIFFFilename}");
         //            shell_exec("tiff2pdf -p A4 -j -q 200 -f -o {$absolutePDFFilename} {$absoluteTIFFFilename}");
         shell_exec("tiff2pdf -p A4 -q 200 -o {$absolutePDFFilename} {$absoluteTIFFFilename}");
         //            shell_exec("tiff2pdf -o {$absolutePDFFilename} {$absoluteTIFFFilename}");
         //Recupera conteúdo
         $pdfData = file_get_contents($absolutePDFFilename);
         //Apaga arquivos PDFs físicos
         unlink($absoluteTIFFFilename);
         unlink($absolutePDFFilename);
     }
     //Retorna FormatoPDF para manipulação
     return new Formato\FormatoPDF("", "{$this->_rowset[0]['DIGITAL']}", $pdfData);
     //        fpassthru( fopen( $absolutePDFFilename, 'r' ) );
 }
 /**
  * @todo Realizar verificação de permissão e parametrizar
  */
 public function getPDF()
 {
     include_once 'fpdf/fpdf.php';
     include_once 'pdfbookmark/PDF_Bookmark.php';
     if ($this->_isConfidentialAuthorized()) {
         $absoluteFileName = $this->_uploadPath . $this->_img_name . '.pdf';
         return new Formato\FormatoPDF($absoluteFileName, $this->_rowset[0]['DIGITAL']);
     } else {
         $pdf = new \PDF_Bookmark();
         $pdf->SetMargins(0, 0, 0);
         $pdf->SetFont('Arial', '', 12);
         $pdf->author = utf8_decode(__CABECALHO_ORGAO__);
         $pdf->title = 'Sistema Gerenciador de Documentos - v' . __VERSAO__;
         $pdf->creator = $pdf->title . ' (' . utf8_decode(\Controlador::getInstance()->usuario->NOME) . ')';
         $key = 0;
         $imagePath = __BASE_PATH__ . '/' . self::CONFIDENCIAL_IMAGE_RELATIVE_FILENAME;
         for ($i = 0; $i < $this->_listaArquivosBehavior->getQuantidadePaginas(); $i++) {
             $pdf->AddPage("P", "A4");
             $pdf->Image($imagePath, 0, 0, 210, 297, "JPG");
             $pdf->Bookmark('Pág. ' . $key + 1);
         }
         $pdfData = $pdf->Output("", 'S');
         return new Formato\FormatoPDF("", "{$this->_rowset[0]['DIGITAL']}", $pdfData);
     }
 }
Beispiel #3
0
<?php

define('FPDF_FONTPATH', 'font/');
require 'bookmark.php';
$pdf = new PDF_Bookmark();
$pdf->Open();
$pdf->SetFont('Arial', '', 15);
//Page 1
$pdf->AddPage();
$pdf->Bookmark('Page 1');
$pdf->Bookmark('Paragraph 1', 1, -1);
$pdf->Cell(0, 6, 'Paragraph 1');
$pdf->Ln(50);
$pdf->Bookmark('Paragraph 2', 1, -1);
$pdf->Cell(0, 6, 'Paragraph 2');
//Page 2
$pdf->AddPage();
$pdf->Bookmark('Page 2');
$pdf->Bookmark('Paragraph 3', 1, -1);
$pdf->Cell(0, 6, 'Paragraph 3');
$pdf->Output();
Beispiel #4
0
 /**
  * @return void
  * @param array $pages
  */
 public function generatePDF($pages, $high = false, $type = 'jpg')
 {
     $allow = AclFactory::checaPermissao(Controlador::getInstance()->acl, Controlador::getInstance()->usuario, DaoRecurso::getRecursoById(999));
     $pdf = new PDF_Bookmark();
     $pdf->SetMargins(0, 0, 0);
     $pdf->SetFont('Arial', '', 12);
     foreach ($pages as $key => $page) {
         if (!$allow && $page['FLG_PUBLICO'] == 0) {
             continue;
         }
         $pdf->author = utf8_decode(__CABECALHO_ORGAO__);
         $pdf->title = 'Sistema Gerenciador de Documentos - v' . __VERSAO__;
         $pdf->creator = $pdf->title . ' (' . utf8_decode(Controlador::getInstance()->usuario->NOME) . ')';
         $imagePath = sprintf('%s/cache/%s/%s/%s_view_%d.jpg', __CAM_UPLOAD__, $this->generateLote($page['DIGITAL']), $page['DIGITAL'], $page['MD5'], $high ? self::Q_HIGH : self::Q_LOW);
         if ($type == 'png') {
             $imagePath = sprintf('%s/%s/%s/%s.png', __CAM_UPLOAD__, $this->generateLote($page['DIGITAL']), $page['DIGITAL'], $page['MD5']);
         }
         if (!is_file($imagePath)) {
             $imagePath = 'imagens/imagem_quebrada_a4.jpg';
         }
         $typeToUp = strtoupper($type);
         if ($page["IMG_WIDTH"] < $page["IMG_HEIGHT"]) {
             $pdf->AddPage("P", "A4");
             $pdf->Image($imagePath, 0, 0, 210, 297, "{$typeToUp}");
         } else {
             $pdf->AddPage("L", "A4");
             $pdf->Image($imagePath, 0, 0, 297, 210, "{$typeToUp}");
         }
         $pdf->Bookmark('Pag. ' . $key + 1);
     }
     $pdf->Output("", 'I');
 }