Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Fix problem with PDF flushing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Cemer committed Nov 5, 2021
1 parent 61f175f commit 0f36c16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ protected function outputHeading($forceNewPage = false) {
$this->outputter->pageNumber++;
$newPage = true;
} else if ($forceNewPage) {
$this->outputter->flushPDF();
$this->outputter->pdf->AddPage();
$this->outputter->pageNumber++;
$newPage = true;
Expand All @@ -192,7 +191,6 @@ protected function outputHeading($forceNewPage = false) {
$hs = $this->outputter->getPDFLineSpacing();
// If we can't the headings on the current page, begin a new page.
if (($this->outputter->pdf->GetY() + $hs) > $this->outputter->pdf->getPageBreakTrigger()) {
$this->outputter->flushPDF();
$this->outputter->pdf->AddPage();
$this->outputter->pageNumber++;
$newPage = true;
Expand Down
26 changes: 11 additions & 15 deletions src/ReportOutputter.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,6 @@ public function createPDF() {
$this->pdfFilePointer = fopen($this->pdfFilename, 'wb');
}

public function flushPDF() {
if ($this->pdfFilePointer !== false) {
if ($this->pdf !== null) {
$data = $this->pdf->Output('S');
$this->pdf->resetBuffer();
if ($data != '') {
fwrite($this->pdfFilePointer, $data, strlen($data));
}
}
}
}

public function outputText($text) {
if ($text != '') {
if ($this->outputStream !== false) {
Expand All @@ -256,9 +244,17 @@ public function finish() {
case 'pdf':
if ($this->pdfFilePointer !== false) {
if ($this->pdf !== null) $this->pdf->Close();
$this->flushPDF();
fclose($this->pdfFilePointer);
$this->pdfFilePointer = false;
if ($this->pdfFilePointer !== false) {
if ($this->pdf !== null) {
$data = $this->pdf->Output('S');
$this->pdf->resetBuffer();
if ($data != '') {
fwrite($this->pdfFilePointer, $data, strlen($data));
}
}
fclose($this->pdfFilePointer);
$this->pdfFilePointer = false;
}
}
if ($this->pdfUseTempFileForOutput) {
$this->output = file_get_contents($this->pdfFilename);
Expand Down

0 comments on commit 0f36c16

Please sign in to comment.