Skip to content

Commit

Permalink
Added more examples to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ruff committed Sep 18, 2023
1 parent 8d64a2c commit 5293189
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [Create HTML markup from existing invoice document (XML) using built-in template](#create-html-markup-from-existing-invoice-document-xml-using-built-in-template)
- [Create a PDF file from existing invoice document (XML) using built-in template](#create-a-pdf-file-from-existing-invoice-document-xml-using-built-in-template)
- [Create a PDF string from existing invoice document (XML) using built-in template](#create-a-pdf-string-from-existing-invoice-document-xml-using-built-in-template)
- [Create a PDF string from document builder and merge XML with generated PDF](#create-a-pdf-string-from-document-builder-and-merge-xml-with-generated-pdf)
- [Create a custom renderer](#create-a-custom-renderer)
- [Use a custom renderer](#use-a-custom-renderer)

Expand Down Expand Up @@ -68,6 +69,8 @@ echo $visualizer->renderMarkup();

### Create a PDF file from existing invoice document (XML) using built-in template

Find there [full example here](https://github.com/horstoeko/zugferdvisualizer/blob/master/examples/BuildFromDocumentReader.php)

```php
use horstoeko\zugferd\ZugferdDocumentReader;
use horstoeko\zugferdvisualizer\ZugferdVisualizer;
Expand Down Expand Up @@ -99,6 +102,28 @@ $visualizer->setPdfFontDefault("courier");
$pdfString = $visualizer->renderPdf();
```

### Create a PDF string from document builder and merge XML with generated PDF

Find there [full example here](https://github.com/horstoeko/zugferdvisualizer/blob/master/examples/BuildFromDocumentBuilder.php)

```php
$document = ZugferdDocumentBuilder::CreateNew(ZugferdProfiles::PROFILE_EN16931);
$document
->setDocumentInformation("471102", "380", \DateTime::createFromFormat("Ymd", "20180305"), "EUR")
->...

$reader = ZugferdDocumentReader::readAndGuessFromContent($document->getContent());

$visualizer = new ZugferdVisualizer($reader);
$visualizer->setDefaultTemplate();
$visualizer->setPdfFontDefault("courier");
$visualizer->setPdfPaperSize('A4-P');

$merger = new ZugferdDocumentPdfMerger($document->getContent(), $visualizer->renderPdf());
$merger->generateDocument();
$merger->saveDocument(dirname(__FILE__) . "/invoice_2.pdf");
```

### Create a custom renderer

If you want to implement your own markup renderer, then your class must implement the interface `ZugferdVisualizerMarkupRendererContract`. The interface defines two methods:
Expand Down

0 comments on commit 5293189

Please sign in to comment.