Skip to content

Commit

Permalink
[FIX] Updated ZugferdDocumentPdfBuilderAbstract -> Remove useless par…
Browse files Browse the repository at this point in the history
…ameter from 'downloadString', Updated DocBlocks
  • Loading branch information
HorstOeko committed Dec 31, 2024
1 parent caf3289 commit 8273bb2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/02_ZugferdDocumentPdfBuilder_EN16931.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
// There is not only the saveDocument method of the ZugferdDocumentPdfBuilder. It is also possible to receive the merged
// content (PDF with embedded XML) as a stream (string)

$mergedPdfContent = $zugferdDocumentPdfBuilder->downloadString('dummy.pdf');
$mergedPdfContent = $zugferdDocumentPdfBuilder->downloadString();

// If you would like to brand the merged PDF with the name of you own solution you can call
// the method setAdditionalCreatorTool. Before calling this method the creator of the PDF is identified as 'Factur-X library 1.x.x by HorstOeko'.
Expand Down
2 changes: 1 addition & 1 deletion examples/02_ZugferdDocumentPdfBuilder_XRECHNUNG.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
// There is not only the saveDocument method of the ZugferdDocumentPdfBuilder. It is also possible to receive the merged
// content (PDF with embedded XML) as a stream (string)

$mergedPdfContent = $zugferdDocumentPdfBuilder->downloadString('dummy.pdf');
$mergedPdfContent = $zugferdDocumentPdfBuilder->downloadString();

// If you would like to brand the merged PDF with the name of you own solution you can call
// the method setAdditionalCreatorTool. Before calling this method the creator of the PDF is identified as 'Factur-X library 1.x.x by HorstOeko'.
Expand Down
26 changes: 11 additions & 15 deletions src/ZugferdDocumentPdfBuilderAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,47 +144,43 @@ public function generateDocument()
}

/**
* Saves the document generated with generateDocument to a file
* Saves the generated PDF document to a file
*
* @param string $toFilename
* The full qualified filename to which the generated PDF (with attachment)
* is stored
* @param string $toFilename The full qualified filename to which the generated PDF (with attachment)is stored
* @return static
*/
public function saveDocument(string $toFilename)
{
$this->pdfWriter->Output($toFilename, 'F');
$this->pdfWriter->Output('F', $toFilename);

return $this;
}

/**
* Returns the PDF as an inline file
* Starts a HTTP download of the generated PDF document
*
* @param string $toFilename
* @return string
*/
public function saveDocumentInline(string $toFilename): string
{
return $this->pdfWriter->Output($toFilename, 'I');
return $this->pdfWriter->Output('I', $toFilename);
}

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

/**
* Sets an additional creator tool (e.g. the ERP software that called the PHP library)
*
* @param string $additionalCreatorTool
* The name of the creator
* @param string $additionalCreatorTool The name of the creator
* @return static
*/
public function setAdditionalCreatorTool(string $additionalCreatorTool)
Expand Down Expand Up @@ -212,9 +208,9 @@ public function getCreatorToolName(): string

/**
* Set the type of relationship for the XML attachment. Allowed
* types are 'Data', 'Alternative'
* types are 'Data', 'Alternative' and 'Source'
*
* @param string $relationshipType
* @param string $relationshipType Type of relationship
* @return static
*/
public function setAttachmentRelationshipType(string $relationshipType)
Expand Down
4 changes: 2 additions & 2 deletions tests/testcases/PdfBuilderEn16931Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testBuildFromSourcePdfFile(): void
$this->assertIsString($pdfContent);
$this->assertNotEquals('', $pdfContent);

$pdfContent = $pdfBuilder->downloadString(self::$destPdfFilename);
$pdfContent = $pdfBuilder->downloadString();

$this->assertNotEquals('', $pdfContent);
$this->assertStringStartsNotWith('%PDF-1.4', $pdfContent);
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testBuildFromSourcePdfString(): void
$this->assertIsString($pdfContent);
$this->assertNotEquals('', $pdfContent);

$pdfContent = $pdfBuilder->downloadString(self::$destPdfFilename);
$pdfContent = $pdfBuilder->downloadString();

$this->assertNotEquals('', $pdfContent);
$this->assertStringStartsNotWith('%PDF-1.4', $pdfContent);
Expand Down

0 comments on commit 8273bb2

Please sign in to comment.