Skip to content

Commit

Permalink
Readme: versions
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Jul 24, 2023
1 parent 9be7f0c commit e1c2dbc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
40 changes: 26 additions & 14 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
### How to prepare PDF from template

```php
use Contributte\PdfResponse\PdfResponse;

// in a Presenter
public function actionPdf()
{
Expand All @@ -25,7 +27,7 @@ public function actionPdf()
$template->someValue = 123;
// Tip: In template to make a new page use <pagebreak>

$pdf = new \Contributte\PdfResponse\PdfResponse($template);
$pdf = new PdfResponse($template);

// optional
$pdf->documentTitle = date("Y-m-d") . " My super title"; // creates filename 2012-06-30-my-super-title.pdf
Expand All @@ -40,12 +42,14 @@ public function actionPdf()
### Save file to server

```php
use Contributte\PdfResponse\PdfResponse;

public function actionPdf()
{
$template = $this->createTemplate();
$template->setFile(__DIR__ . "/path/to/template.latte");

$pdf = new \Contributte\PdfResponse\PdfResponse($template);
$pdf = new PdfResponse($template);

$pdf->save(__DIR__ . "/path/to/directory"); // as a filename $this->documentTitle will be used
$pdf->save(__DIR__ . "/path/to/directory", "filename"); // OR use a custom name
Expand All @@ -55,12 +59,14 @@ public function actionPdf()
### Attach file to an email

```php
use Contributte\PdfResponse\PdfResponse;

public function actionPdf()
{
$template = $this->createTemplate();
$template->setFile(__DIR__ . "/path/to/template.latte");

$pdf = new \Contributte\PdfResponse\PdfResponse($template);
$pdf = new PdfResponse($template);

$savedFile = $pdf->save(__DIR__ . "/path/to/directory");
$mail = new Nette\Mail\Message;
Expand All @@ -74,12 +80,14 @@ public function actionPdf()
### Force file to download

```php
use Contributte\PdfResponse\PdfResponse;

public function actionPdf()
{
$template = $this->createTemplate();
$template->setFile(__DIR__ . "/path/to/template.latte");

$pdf = new \Contributte\PdfResponse\PdfResponse($template);
$pdf = new PdfResponse($template);
$pdf->setSaveMode(PdfResponse::DOWNLOAD); //default behavior
$this->sendResponse($pdf);
}
Expand All @@ -88,12 +96,14 @@ public function actionPdf()
### Force file to display in a browser

```php
use Contributte\PdfResponse\PdfResponse;

public function actionPdf()
{
$template = $this->createTemplate();
$template->setFile(__DIR__ . "/path/to/template.latte");

$pdf = new \Contributte\PdfResponse\PdfResponse($template);
$pdf = new PdfResponse($template);
$pdf->setSaveMode(PdfResponse::INLINE);
$this->sendResponse($pdf);
}
Expand All @@ -102,9 +112,11 @@ public function actionPdf()
### Set a pdf background easily

```php
use Contributte\PdfResponse\PdfResponse;

public function actionPdf()
{
$pdf = new \Contributte\PdfResponse\PdfResponse('');
$pdf = new PdfResponse('');
$pdf->setBackgroundTemplate(__DIR__ . "/path/to/an/existing/file.pdf");

// to write into an existing document use the following statements
Expand All @@ -124,6 +136,8 @@ public function actionPdf()
### Create pdf with latte only

```php
use Contributte\PdfResponse\PdfResponse;

public function actionPdf()
{
$latte = new Latte\Engine;
Expand All @@ -136,7 +150,7 @@ public function actionPdf()

$template = $latte->renderToString(__DIR__ . "/path/to/template.latte");

$pdf = new \Contributte\PdfResponse\PdfResponse($template);
$pdf = new PdfResponse($template);
$this->sendResponse($pdf);
}
```
Expand All @@ -154,12 +168,11 @@ services:
and in your PHP code:

```php
/**
* @var \Contributte\PdfResponse\PdfResponse
*/
public $pdfResponse;
use Contributte\PdfResponse\PdfResponse;

private PdfResponse $pdfResponse;

public function __construct(\Contributte\PdfResponse\PdfResponse $pdfResponse)
public function __construct(PdfResponse $pdfResponse)
{
$this->pdfResponse = $pdfResponse;
}
Expand All @@ -168,11 +181,10 @@ public function actionPdf()
{
$template = $this->createTemplate();
$template->setFile(__DIR__ . "/path/to/template.latte");

$this->pdfResponse->setTemplate($template);

$this->pdfResponse->setSaveMode(PdfResponse::INLINE);
$this->sendResponse($this->pdfResponse);
}

```
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ For details on how to use this package, check out our [documentation](.docs).

## Versions

| State | Version | Branch | PHP |
|-------------|-------------|----------|----------|
| dev | `6.1.x-dev` | `master` | `^7.1` |
| stable | `^6.1` | `master` | `^7.1` |
| State | Version | Branch | PHP |
|-------------|---------|----------|--------|
| dev | `^7.1` | `master` | `8.1+` |
| stable | `^7.0` | `master` | `8.1+` |

## Development

Expand Down

0 comments on commit e1c2dbc

Please sign in to comment.