diff --git a/src/ZugferdDocumentPdfBuilder.php b/src/ZugferdDocumentPdfBuilder.php index 2f1945d..67214b7 100644 --- a/src/ZugferdDocumentPdfBuilder.php +++ b/src/ZugferdDocumentPdfBuilder.php @@ -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 diff --git a/tests/testcases/PdfBuilderEn16931Test.php b/tests/testcases/PdfBuilderEn16931Test.php index e83e626..bd4ef6b 100644 --- a/tests/testcases/PdfBuilderEn16931Test.php +++ b/tests/testcases/PdfBuilderEn16931Test.php @@ -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();