Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add margin-header and margin-footer configuration #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions Classes/View/PdfView.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ protected function getPdfObject()
// Get options from TypoScript
$pageFormat = ($this->options->getPdfPageFormat()) ? $this->options->getPdfPageFormat() : 'A4';
$pageOrientation = ($orientation = $this->options->getPdfPageOrientation()) ? $orientation : 'L';
$leftMargin = ($this->options->getPdfLeftMargin()) ? $this->options->getPdfLeftMargin() : '15';
$rightMargin = ($this->options->getPdfRightMargin()) ? $this->options->getPdfRightMargin() : '15';
$bottomMargin = ($this->options->getPdfBottomMargin()) ? $this->options->getPdfBottomMargin() : '15';
$topMargin = ($this->options->getPdfTopMargin()) ? $this->options->getPdfTopMargin() : '15';
$leftMargin = ($this->options->getPdfLeftMargin() || $this->options->getPdfLeftMargin() == 0) ? $this->options->getPdfLeftMargin() : '15';
$rightMargin = ($this->options->getPdfRightMargin() || $this->options->getPdfRightMargin() == 0) ? $this->options->getPdfRightMargin() : '15';
$bottomMargin = ($this->options->getPdfBottomMargin() || $this->options->getPdfBottomMargin() == 0) ? $this->options->getPdfBottomMargin() : '15';
$topMargin = ($this->options->getPdfTopMargin() || $this->options->getPdfTopMargin() == 0) ? $this->options->getPdfTopMargin() : '15';
$headerMargin = ($this->options->getPdfHeaderMargin() || $this->options->getPdfHeaderMargin() == 0) ? $this->options->getPdfHeaderMargin() : '9';
$footerMargin = ($this->options->getPdfFooterMargin() || $this->options->getPdfFooterMargin() == 0) ? $this->options->getPdfFooterMargin() : '9';
$styleSheet = ($this->options->getPdfStyleSheet()) ? $this->options->getPdfStyleSheet() : 'print';

/* @var $pdf Mpdf */
Expand All @@ -170,6 +172,8 @@ protected function getPdfObject()
'margin_right' => $rightMargin,
'margin_top' => $topMargin,
'margin_bottom' => $bottomMargin,
'margin_header' => $headerMargin,
'margin_footer' => $footerMargin,
'orientation' => $pageOrientation,
'tempDir' => PATH_site . 'typo3temp',
'fontDir' => ExtensionManagementUtility::extPath('web2pdf') . 'Resources/Public/Fonts',
Expand Down
4 changes: 4 additions & 0 deletions Configuration/TypoScript/constants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ plugin.tx_web2pdf {
useCustomFooter = 0
# cat=plugin.tx_web2pdf/pdf/10; type=boolean; label=LLL:EXT:web2pdf/Resources/Private/Language/locallang.xlf:constants.pdf.useCustomHeader
useCustomHeader = 0
# cat=plugin.tx_web2pdf/pdf/11; type=int+; label=LLL:EXT:web2pdf/Resources/Private/Language/locallang.xlf:constants.pdf.headerMargin
pdfHeaderMargin = 9
# cat=plugin.tx_web2pdf/pdf/12; type=int+; label=LLL:EXT:web2pdf/Resources/Private/Language/locallang.xlf:constants.pdf.footerMargin
pdfFooterMargin = 9

}
}
2 changes: 2 additions & 0 deletions Configuration/TypoScript/setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ plugin.tx_web2pdf {
pdfRightMargin = {$plugin.tx_web2pdf.settings.pdfRightMargin}
pdfTopMargin = {$plugin.tx_web2pdf.settings.pdfTopMargin}
pdfBottomMargin = {$plugin.tx_web2pdf.settings.pdfBottomMargin}
pdfHeaderMargin = {$plugin.tx_web2pdf.settings.pdfHeaderMargin}
pdfFooterMargin = {$plugin.tx_web2pdf.settings.pdfFooterMargin}
pdfStyleSheet = {$plugin.tx_web2pdf.settings.pdfStyleSheet}
pdfDestination = {$plugin.tx_web2pdf.settings.pdfDestination}
useCustomHeader = {$plugin.tx_web2pdf.settings.useCustomHeader}
Expand Down
6 changes: 6 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<trans-unit id="constants.pdf.leftMargin">
<source>Left margin</source>
</trans-unit>
<trans-unit id="constants.pdf.headerMargin">
<source>Header margin</source>
</trans-unit>
<trans-unit id="constants.pdf.footerMargin">
<source>Footer margin</source>
</trans-unit>
<trans-unit id="constants.pdf.fontSize">
<source>Default font size</source>
</trans-unit>
Expand Down