Skip to content

Commit

Permalink
Added new output FpdfOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
Franco2911 committed Jul 1, 2020
1 parent 1a111c3 commit 1eb4b16
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 37 deletions.
Binary file added assets/marks_30x10mm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/marks_40x15mm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/marks_52x20mm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/marks_65x25mm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
"symfony/css-selector": "^4.2",
"phpstan/phpstan": "^0.12.23",
"friendsofphp/php-cs-fixer": "^2.16",
"tecnickcom/tcpdf": "^6.3.2"
"symfony/var-dumper": "^5.1",
"tecnickcom/tcpdf": "^6.3.2",
"fpdf/fpdf": "^1.82"
},
"suggest": {
"tecnickcom/tcpdf": "Needed to create pdfs with TcPdfOutput"
"tecnickcom/tcpdf": "Needed to create pdfs with TcPdfOutput",
"fpdf/fpdf": "Needed to create pdfs with FpdfOutput"
},
"autoload": {
"psr-4": {
Expand Down
185 changes: 151 additions & 34 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions example/FpdfOutput/fpdf-example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Sprain\SwissQrBill\PaymentPart\Output\FpdfOutput\Template\QrBillFooter;

require dirname(dirname(__DIR__)) . '/vendor/autoload.php';

// 1. Let's load the base example to define the qr bill contents
require dirname(__DIR__) . '/example.php';

// 2. Create a FPDF instance (or use an existing one from your project)
$fpdf = new QrBillFooter('P', 'mm', 'A4');
$fpdf->AddPage();

// 3. Create a full payment part for FPDF
$output = new Sprain\SwissQrBill\PaymentPart\Output\FpdfOutput\fpdfOutput($qrBill, 'en', $fpdf);
$output
->setPrintable(false)
->getPaymentPart();

// 4. For demo purposes, let's save the generated example in a file
$examplePath = __DIR__ . "/fpdf_example.pdf";
$fpdf->Output($examplePath, 'F');

if (file_exists(dirname(__DIR__) . '/qr.svg')) {
unlink(dirname(__DIR__) . '/qr.svg');
unlink(dirname(__DIR__) . '/qr.png');
}

print "PDF example created here : " . $examplePath;
6 changes: 5 additions & 1 deletion src/PaymentPart/Output/Element/Placeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ public function getType(): ?string
return $this->type;
}

public function getFile(): ?string
// TODO: Not tested, need to create an example_non to test Placeholders
public function getFile(?string $ext = 'svg'): ?string
{
if ($ext === 'png') {
$this->file = str_replace('.svg', '.png', $this->file);
}
return $this->file;
}

Expand Down
Loading

0 comments on commit 1eb4b16

Please sign in to comment.