Skip to content

Commit

Permalink
Add string output as option
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo124 committed Aug 16, 2023
1 parent 725c130 commit 2d27efa
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 2d27efa

Please sign in to comment.