Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Added new method, view(), for use when debugging #129

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/LaravelPdf/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
*/
class Pdf {

protected $html = '';
protected $config = [];

public function __construct($html = '', $config = [])
{
$this->html = $html;
$this->config = $config;

// @see https://mpdf.github.io/reference/mpdf-functions/construct.html
Expand Down Expand Up @@ -54,7 +56,7 @@ public function __construct($html = '', $config = [])
$this->config['instanceConfigurator']($this->mpdf);
}

$this->mpdf->WriteHTML($html);
$this->mpdf->WriteHTML($this->html);
}

protected function getConfig($key)
Expand Down Expand Up @@ -142,4 +144,15 @@ public function stream($filename = 'document.pdf')
{
return $this->mpdf->Output($filename, 'I');
}

/**
* Return the rendered view as an HTML string to show in the browser.
* Useful for debugging the HTML code to see what it looks like.
*
* @return string
*/
public function view()
{
return $this->html;
}
}