Skip to content
This repository has been archived by the owner on Jun 6, 2020. It is now read-only.

Commit

Permalink
ability to pass options to getDOM()
Browse files Browse the repository at this point in the history
  • Loading branch information
wernerkrauss committed Mar 6, 2017
1 parent 4b0c2c6 commit 53d736f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/Html.php
Expand Up @@ -11,21 +11,29 @@ class Html extends Dom
{
protected $contents, $total_pages, $current_page, $pdf_file, $locked = false;

public function __construct($pdf_file)
protected $default_options = [
'singlePage' => true,
'noFrames' => false,
];

public function __construct($pdf_file, $options = [])
{
$this->getContents($pdf_file);
$options = array_merge($this->default_options, $options);

$this->getContents($pdf_file, $options);

return $this;
}

private function getContents($pdf_file)
/**
* @param $pdf_file
* @param array $options
*/
private function getContents($pdf_file, $options)
{
$this->locked = true;
$info = new Pdf($pdf_file);
$pdf = new Base($pdf_file, [
'singlePage' => true,
'noFrames' => false,
]);
$pdf = new Base($pdf_file, $options);
$pages = $info->getPages();

$random_dir = uniqid();
Expand Down
8 changes: 4 additions & 4 deletions src/Pdf.php
Expand Up @@ -49,16 +49,16 @@ protected function info()
return $this;
}

public function getDom()
public function getDom($options = [])
{
$this->checkInfo();

return new Html($this->file);
return new Html($this->file, $options);
}

public function html($page = 1)
public function html($page = 1, $options = [])
{
$dom = $this->getDom();
$dom = $this->getDom($options);

return $dom->raw($page);
}
Expand Down

0 comments on commit 53d736f

Please sign in to comment.