Skip to content

Commit

Permalink
Merge pull request #16 from turbo124/add_string_output_for_pdf
Browse files Browse the repository at this point in the history
Add string output as option
  • Loading branch information
horstoeko authored Aug 16, 2023
2 parents 725c130 + 2d27efa commit 5ee0f3c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/ZugferdDocumentPdfBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ public function saveDocument(string $toFilename): ZugferdDocumentPdfBuilder

return $this;
}

/**
* Returns the PDF as a string
*
* @param string $toFilename
* @return string
*/
public function downloadString(string $toFilename): string
{
return $this->pdfWriter->Output($toFilename, 'S');
}

/**
* Internal function which sets up the PDF
Expand Down
9 changes: 9 additions & 0 deletions tests/testcases/PdfBuilderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ public function testBuildPdf(): void
$this->assertTrue(file_exists(self::$destPdfFilename));
}

public function testBuildPdfString(): void
{
$pdfBuilder = new ZugferdDocumentPdfBuilder(self::$document, self::$sourcePdfFilename);
$pdfBuilder->generateDocument();
$pdfBuilder->downloadString(self::$destPdfFilename);

$this->assertIsString(self::$destPdfFilename);
}

public function testPdfMetaData(): void
{
$pdfParser = new PdfParser();
Expand Down

0 comments on commit 5ee0f3c

Please sign in to comment.