Skip to content

Commit

Permalink
Merge pull request bithost-gmbh#98 from bithost-gmbh/feature/pdfCompl…
Browse files Browse the repository at this point in the history
…iance

Fixes a PDF 1.7 compliance issue
  • Loading branch information
maechler authored Oct 18, 2018
2 parents 3ace909 + ebb381b commit 3df668a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for TYPO3 CMS Extension pdfviewhelpers

## 2.0.1 - October 18, 2018
- Fixes a PDF 1.7 compliance issue, [#97](https://github.com/bithost-gmbh/pdfviewhelpers/issues/97)
- Updates documentation

## 2.0.0 - October 4, 2018
- Adds HeaderViewHelper and FooterViewHelper, [#31](https://github.com/bithost-gmbh/pdfviewhelpers/issues/31)
- Adds PageNumberAliasViewHelper and TotalNumberOfPagesAliasViewHelpers, [#31](https://github.com/bithost-gmbh/pdfviewhelpers/issues/31)
Expand Down
34 changes: 9 additions & 25 deletions Classes/Model/BasePDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,24 @@ class BasePDF extends Fpdi
*/
protected function setHeader()
{
//disable TCPDF default behaviour in order to be able to overwrite header and footer on page level
//disable TCPDF default behaviour in order to be able to overwrite header on page level
}

/**
* @inheritdoc
*/
protected function setFooter()
public function endPage($tocpage = false)
{
//disable TCPDF default behaviour in order to be able to overwrite header and footer on page level
parent::endPage($tocpage);

if ($this->pageFooterScope === self::SCOPE_THIS_PAGE) {
$this->pageFooterClosure = null; //remove page footer closure as it should only be used once
}
}

/**
* Custom method to call setHeader to render header after the children of a PageViewHelper are rendered.
* This allows to overwrite header within a PageViewHelper.
* This allows to overwrite the header within a PageViewHelper.
*
* @return void
*/
Expand All @@ -127,23 +131,8 @@ public function renderHeader()
$graphicVars = $this->getGraphicVars();

parent::setHeader();

$this->setGraphicVars($graphicVars);
}

/**
* Custom method to call setFooter to render footer after the children of a PageViewHelper are rendered.
* This allows to overwrite footer within a PageViewHelper.
*
* @return void
*/
public function renderFooter()
{
$graphicVars = $this->getGraphicVars();

parent::setFooter();

$this->setGraphicVars($graphicVars);
$this->setPageMark();
}

/**
Expand Down Expand Up @@ -204,12 +193,7 @@ public function AddPage($orientation = '', $format = '', $rotationOrKeepmargins
$this->pageHeaderClosure = null; //remove page header closure as it should only be used once
}

if ($this->pageFooterScope === self::SCOPE_THIS_PAGE) {
$this->pageFooterClosure = null; //remove page footer closure as it should only be used once
}

$this->renderHeader();
$this->renderFooter();
}

if ($this->importTemplateOnThisPage && $this->tpl !== 0) {
Expand Down
1 change: 0 additions & 1 deletion Classes/ViewHelpers/AbstractContentElementViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ protected function initializeHeaderAndFooter()
$this->viewHelperVariableContainer->addOrUpdate('DocumentViewHelper', 'pageNeedsHeader', false);

$this->getPDF()->renderHeader();
$this->getPDF()->renderFooter();
}
}

Expand Down
10 changes: 4 additions & 6 deletions Classes/ViewHelpers/PageViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,20 @@ public function render()

$this->setPageNeedsHeader(true);
$this->getPDF()->setIsAutoPageBreak(true);
$this->getPDF()->setHeaderClosure(null, BasePDF::SCOPE_THIS_PAGE_INCLUDING_PAGE_BREAKS);
$this->getPDF()->setFooterClosure(null, BasePDF::SCOPE_THIS_PAGE_INCLUDING_PAGE_BREAKS);
$this->getPDF()->setImportTemplateOnThisPage($hasImportedPage && $this->arguments['importPageOnAutomaticPageBreak']);

$this->renderChildren();

if ($this->pageNeedsHeader()) {
//no auto page break occurred, we still need to set the header
//no auto page break occurred or no element was rendered, we still need to set the header
$this->setPageNeedsHeader(false);

$this->getPDF()->renderHeader();
$this->getPDF()->renderFooter();
}

//reset default header and footer scope to document and reset header and footer closures
//reset default header and footer scope to document
$this->setDefaultHeaderFooterScope(BasePDF::SCOPE_DOCUMENT);
$this->getPDF()->setHeaderClosure(null, BasePDF::SCOPE_THIS_PAGE_INCLUDING_PAGE_BREAKS);
$this->getPDF()->setFooterClosure(null, BasePDF::SCOPE_THIS_PAGE_INCLUDING_PAGE_BREAKS);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ Extend Existing PDFs
--------------------

It is possible to use existing PDFs as template and extend the PDF where needed. You can either load the template PDF
within the TypoScript settings or within the Fluid template itself. When you want to use that feature your PDF class should
extend the class ``Bithost\Pdfviewhelpers\Model\BasePDF``. It is however also possible to use the class ``\FPDI``, although
not recommend because it does not support all ``EXT:pdfviewhelpers`` features.
within the TypoScript settings or within the Fluid template itself.

TypoScript
""""""""""
Expand Down
4 changes: 2 additions & 2 deletions Documentation/Settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
conf.py:
copyright: 2016 - 2018
project: PDF ViewHelpers
version: 2.0.0
release: 2.0.0
version: 2.0.1
release: 2.0.1
intersphinx_mapping:
t3tsref:
- http://docs.typo3.org/typo3cms/TyposcriptReference/
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bithost-gmbh/pdfviewhelpers",
"type": "typo3-cms-extension",
"version": "2.0.0",
"version": "2.0.1",
"license": "GPL-3.0",
"description": "This is a TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.",
"keywords": ["PDF", "ViewHelpers", "Fluid", "generation", "generator", "TCPDF", "FPDI"],
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'uploadfolder' => '0',
'createDirs' => '',
'clearCacheOnLoad' => 0,
'version' => '2.0.0',
'version' => '2.0.1',
'constraints' => [
'depends' => [
'typo3' => '7.6.0-9.5.99',
Expand Down

0 comments on commit 3df668a

Please sign in to comment.