[TYPO3-german] Lösung pdf_creator2 - custom header/footer/cover

Alex Ru alex at ruof.org
Fri Sep 19 09:56:47 CEST 2014


Hallo zusammen,

hier die Änderungen für eigene header.html, footer.html und cover.html (erste Seite), wie sie auch an den Entwickler der Extension gehen und die er so auch einpflegen wird und es dann eine Neue Version im TER geben wird. Leider in Englisch, da es so an den Entwickler geht. und Farben fehlen leider auch.

Getestet unter 4.5.35

Wer nicht auf die neue Version warten will, kann die Änderungen selbst Durchführen. Ansonsten gibt es je nach Geschwindigkeit vom Entwickler bald eine neue Version im TER.

Extending pdf_creator2 for usage of custom header.html, custom footer.html and cover (first page added without header/footer) over cover html.
> Lines are added
< Lines are removed or commented out

Changes made in source code:
In ext_typoscript_constants.txt added at the end
># extras by A. Ruof for custom header/footer and cover
>pdf_creator2.my_header = typo3conf/ext/pdf_creator2/res/header.html
>pdf_creator2.my_footer = typo3conf/ext/pdf_creator2/res/footer.html
>pdf_creator2.my_coverActive = 0
>pdf_creator2.my_cover = typo3conf/ext/pdf_creator2/res/cover.html

in ext_typoscript_constants.txt added at the end
># extras by A. Ruof for custom header/footer and cover
>config.pdf_creator2.my_header = {$pdf_creator2.my_header}
>config.pdf_creator2.my_footer = {$pdf_creator2.my_footer}
>config.pdf_creator2.my_coverActive = {$pdf_creator2.my_coverActive}
>config.pdf_creator2.my_cover = {$pdf_creator2.my_cover}

in gen_pdf.php added at the end of //---------------------------- parse html2df parameters --------------
># extras by A. Ruof for custom header/footer and cover
>$html2pdf_my_header=$GLOBALS{TSFE}->config['config']['pdf_creator2.']['my_header'];
>$html2pdf_my_footer=$GLOBALS{TSFE}->config['config']['pdf_creator2.']['my_footer'];
>$html2pdf_my_coverActive=$GLOBALS{TSFE}->config['config']['pdf_creator2.']['my_coverActive'];
>$html2pdf_my_cover=$GLOBALS{TSFE}->config['config']['pdf_creator2.']['my_cover'];

In gen_pdf.php Changed  the $wkh_params array
># extras by A. Ruof for custom header/footer and cover
>$cover =  PATH_site . $html2pdf_my_cover;
$wkh_params = array(
        'path' => PATH_site.'typo3temp/',
        'page_size' => $html2pdf_size,
>        'coverActive' => $html2pdf_my_coverActive,
>        'cover' => $cover,
        'margins' => 
            array ( 'left'   => $html2pdf_left,
                    'right'  => $html2pdf_right,
                    'top'    => $html2pdf_top,
                    'bottom' => $html2pdf_bottom
            )
    );

In gen_pdf.php change the code for paths of header / footer
>// original header footer  
<// $footer = "file://". t3lib_extMgm::extPath('pdf_creator2','res/footer.html?url='.$urll.'&ndate='.$ndate);
<// $header = t3lib_extMgm::extPath('pdf_creator2','res/header.html');
    
># extras by A. Ruof for custom header/footer and cover
>$footer = 'file://' . PATH_site . $html2pdf_my_footer .'?url='.$urll.'&ndate='.$ndate;
>$header = $html2pdf_my_header;

In class.pc_wkhtmltopdf.php
Added at getters/setters
># extras by A. Ruof for custom header/footer and cover
>protected $_coverHtml;
>protected $_coverActive = false;

At public function __construct(array $options = array()) add before $this->setPath($options['path']);
># extras by A. Ruof for custom header/footer and cover
>if (array_key_exists('cover', $options)) {
>    $this->setCoverHtml($options['cover']);
>}
>if (array_key_exists('coverActive', $options)) {
>    $this->setCoverActive($options['coverActive']);
>}

After public function getPassword() { ... } add
># extras by A. Ruof for custom header/footer and cover
>public function setCoverHtml($cover)
>{
>    $this->_coverHtml = (string)$cover;
>    return $this;
>}
    
>public function getCoverHtml()
>{
>    return $this -> _coverHtml;
>}

>public function setCoverActive($coverActive = true)
>{
>    $this->_coverActive = (boolean)$coverActive;
>    return $this;
>}

>public function getCoverActive()
>{
>    return $this->_coverActive;
>}


Directly before $command .= ' "%input%"'; add

$command .= ($this->getTitle()) ? ' --title "' . $this->getTitle() . '"' : '';

># extras by A. Ruof for custom header/footer and cover
>$command .= ($this->getCoverActive()) ? " cover \"" . $this->getCoverHtml() . "\" " : "";

$command .= ' "%input%"';



Now create a template or add in your template  in Constants field:
pdf_creator2.my_header = fileadmin/template/pdf/header.html
pdf_creator2.my_footer = fileadmin/template/pdf/footer.html
pdf_creator2.my_cover = fileadmin/template/pdf/cover.html
pdf_creator2.my_coverActive = 1

if you set this to zero, the cover is disabled:
pdf_creator2.my_coverActive = 0


Gruß

Alex


More information about the TYPO3-german mailing list