Я создаю приложение, которое требует производства файлов PDF. Я использую FPDF и FPDI. Иногда приложение требует многократного вызова библиотечного класса в форме foreach l oop. Но каждый раз, когда мне нужно несколько звонков, он останавливается после первого. Также класс, кажется, открывает пустое окно.
Если кто-то может произвести логическое объяснение, я был бы очень счастлив.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Maak een pdf
*/
class CreatePdf
{
/**
* Maak de pdf
* @param $data collection of input data
* @param $sourceFile basis pdf bestands locatie
* */
public function create($data, $sourceFile)
{
require_once('PDF_Textbox.php');
// initializeer FPDI in ladnscape
// $pdf = new Fpdi('L');
$pdf = new PDF_TextBox('L');
// Nieuwe pagina
$pdf->AddPage();
$pdf->setSourceFile($sourceFile);
$tpl = $pdf->importPage(1);
/* Gebruik de nieuwe pagina als een template op de achtergrond
* Dit met de volledige breedte en hoogte */
$pdf->useTemplate($tpl, 0, 0, null, null);
// Set font en kleur
$pdf->SetFont('Helvetica', 'B', 8);
$pdf->SetTextColor(0, 0, 0);
foreach($data['single'] as $single)
{
$pdf->Text($single[0], $single[1], $single[2]);
}
foreach($data['textbox'] as $textbox)
{
$pdf->SetXY($textbox[0], $textbox[1]);
$pdf->drawTextBox($textbox[2], $textbox[3], $textbox[4], $textbox[5], $textbox[6], $textbox[7]);
}
/* Output our new pdf into a file
* F = Write local file
* I = Send to standard output (browser)
* D = Download file
* S = Return PDF as a string */
$pdf->Output(APPPATH . '../docs/s627-'. date("d-m-Y-H.i.s") .'.pdf', 'F');
}
}
/**
* Verzamel alle data en creeër de documenten
*/
public function create_s627()
{
$input = $this->collectInput();
if(!empty($input))
{
$sourceFiles = $this->getSourceFiles($input['checkbox']);
foreach($sourceFiles as $sourceFile)
{
$this->createpdf->create($input, $sourceFile);
}
}
else
{
echo "Data was leeg";
}
}
array(3) {
[0]=>
string(31) "./assets/base/S627-bis-lvhw.pdf"
[1]=>
string(29) "./assets/base/S627-bis-wl.pdf"
[2]=>
string(22) "./assets/base/S627.pdf"
}