ob_start();
use setasign\Fpdi\Fpdi;
require(‘fpdf184/fpdf.php’);
require(‘FPDI-2.3.6/src/autoload.php’);
require(‘TCPDF-main/tcpdf.php’);
require(‘TCPDF-main/examples/tcpdf_include.php’);
$pdf = new Fpdi();
$myHtml = “<center><h1 style=margin-bottom:50px;>SUMARIO</h1><table class=’table table-stripped’>”;
foreach ($matrizArquivos as $meuArquivo) {
$myHtml .= “<tr><td>$meuArquivo</td></tr>”;
}
$myHtml .= “</table></center”;
// $pdf->add_page()
// # Displaying a full-width cell with centered text:
// $pdf->cell(w=$pdf->epw, txt=”Welcome on first page!”, align=”C”)
// $pdf->add_page()
// link = $pdf->add_link()
// $pdf->set_link(link, page=1)
// $pdf->cell(txt=”Internal link to first page”, border=1, link=link)
foreach ($matrizArquivos as $arquivo) {
$pageCount = $pdf->setSourceFile(‘boletim_eletronico_notas_dp_anexos/’.$arquivo);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
$pdf->addPage();
// use the imported page
$pdf->useTemplate($templateId);
$pdf->SetFont(‘Helvetica’, ‘B’, 7);
$pdf->SetXY(5, 5);
$pdf->Cell(0,5,’Paginacao Geral: ‘ . $pdf->PageNo() .’ Pag. Documento: ‘ . $pageNo . “/” . $pageCount, 0 , 0 , ‘L’);
$link = $pdf->addLink();
$pdf->SetLink($link);
}
}
// foreach ($matrizArquivos as $arquivo) {
// $pageCount = $pdf->setSourceFile(‘boletim_eletronico_notas_dp_anexos/’.$arquivo);
// for ($i = 0; $i < $pageCount; $i++) {
// $tpl = $pdf->importPage($i + 1);
// $pdf->addPage();
// $pdf->useTemplate($tpl);
// }
// }
$pdf->SetFont(‘Times’,”,12);
$pdf->AddPage();
$pdf->Cell(0,5,’SUMARIO’,0,1,’C’);
//$pdf->firstPage();
// $pdf->addTOCPage();
// $link = $pdf->AddLink();
// $pdf->SetLink($link, 0, ‘*1’);
// $pdf->addTOC(2, ‘courier’, ‘.’, ‘INDEX’, ‘R’, array(128,0,0));
// $pdf->endTOCPage();
$arquivodesaida = $idproduto;
//Dowload direto
$pdf->Output(‘F’, ‘boletim_eletronico_notas_dp_anexos/’. $arquivodesaida . ‘.pdf’);
ob_end_flush();
echo ‘<a href=”boletim_eletronico_notas_dp_anexos/’ . $arquivodesaida . ‘.pdf” class=”btn btn-xs btn-danger” target=”_blank”>Baixar Arquivo único</a>’;
//echo $myHtml;
//file_put_contents(“teste”, $fpdi->Output(”, ‘S’));