Giter Club home page Giter Club logo

pdfviewhelpers's Introduction

TYPO3 TYPO3 Build Status Packagist Downloads Donate

TYPO3 CMS Extension pdfviewhelpers

Introduction

This is a TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents. Using the ViewHelpers from this extension you can make any Fluid template into a PDF document. The extension pdfviewhelpers is using TCPDF and FPDI for the PDF generation.

Key features

  • ViewHelpers to render text and lists
  • ViewHelper to render images (supporting FAL and image processing)
  • ViewHelpers to repeatedly render header and footer
  • ViewHelper to render HTML / rich-text content
  • ViewHelper to avoid page breaks inside
  • ViewHelpers to create a multi column layout
  • ViewHelpers to create a table of content
  • Load existing PDF documents as template
  • Define and apply different text types easily
  • Fully customizable by writing your own ViewHelpers
  • Supports batch creation of PDFs
  • Supported output destinations: string, inline, download and file
  • Usable both in frontend and backend
  • Rich inheritance based TypoScript settings
  • Rich API documentation with lots of examples

Support Development

With the extension pdfviewhelpers we try to take the pain out of creating PDF documents. We aim at providing the best service possible by constantly improving the extension and responding fast to bug reports. We do this fully free of cost, mostly because we love to code and share. However we are still human and have human needs like food, shelter and beer. So if you feel like this extension was useful to you and saved you and your business some precious time, please consider making a donation to support its maintenance and further development.

PayPal

Links

Topic Link
Bug Tracker https://github.com/bithost-gmbh/pdfviewhelpers/issues
Git Repository https://github.com/bithost-gmbh/pdfviewhelpers
TER https://typo3.org/extensions/repository/view/pdfviewhelpers
Packagist https://packagist.org/packages/bithost-gmbh/pdfviewhelpers
Full Documentation https://docs.typo3.org/p/bithost-gmbh/pdfviewhelpers/master/en-us/
Changelog https://github.com/bithost-gmbh/pdfviewhelpers/blob/master/CHANGELOG.md
Sponsoring PayPal
Contact @maechler, @macjohnny, https://www.bithost.ch/kontakt/

Example

Fluid Template

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      xmlns:pdf="http://typo3.org/ns/Bithost/Pdfviewhelpers/ViewHelpers"
      xsi:schemaLocation="http://typo3.org/ns/Bithost/Pdfviewhelpers/ViewHelpers https://pdfviewhelpers.bithost.ch/schema/3.0.xsd"
      data-namespace-typo3-fluid="true">
    
<pdf:document outputDestination="inline" title="Bithost Example">
    <pdf:header>
        <pdf:image src="EXT:pdfviewhelpers/Resources/Public/Examples/BasicUsage/logo.png" width="40" />
        <pdf:text alignment="right" color="#8C8C8C" paragraphSpacing="0" posY="15">
            Bithost GmbH
            Milchbuckstrasse 83
            CH-8057 Zürich
    
            [email protected]
            044 585 28 20
    
            www.bithost.ch
        </pdf:text>
    </pdf:header>
    <pdf:footer>
        <pdf:graphics.line style="{color: '#8C8C8C'}" />
        <pdf:text color="#8C8C8C">Page {pdf:getPageNumberAlias()}</pdf:text>
        <pdf:text alignment="right" color="#8C8C8C" posY="-13.5">EXT:pdfviewhelpers - Basic usage example</pdf:text>
    </pdf:footer>
    
    <pdf:page>
        <pdf:text posY="50" padding="{bottom: 4}" color="#8C8C8C">
            Zurich, <f:format.date format="d.m.Y" >now</f:format.date>
        </pdf:text>
        <pdf:headline>Welcome to the extension pdfviewhelpers</pdf:headline>
        <pdf:text>Lorem ipsum [..] diam voluptua:</pdf:text>
        <pdf:headline>Some more information</pdf:headline>
    
        <pdf:multiColumn>
            <pdf:column width="55%">
                <pdf:text>
                    Lorem ipsum [..] voluptua:
                </pdf:text>
                <pdf:list listElements="{0: 'Full Stack Application Development', 1: 'Modernizing, Refactoring [..]'}" />
                <pdf:text>
                    Lorem ipsum [..] sit amet.
                </pdf:text>
            </pdf:column>
            <pdf:column width="45%" padding="{left: 2}">
                <pdf:image src="EXT:pdfviewhelpers/Resources/Public/Examples/BasicUsage/Bithost.jpg" link="https://bithost.ch/" />
                <pdf:text padding="{top: 1}" color="#8C8C8C">Esteban Gehring, Markus Mächler</pdf:text>
            </pdf:column>
        </pdf:multiColumn>
    
        <pdf:text>Lorem ipsum [..] sit amet.</pdf:text>
        <pdf:text>Lorem ipsum [..] sit amet.</pdf:text>
    </pdf:page>
</pdf:document>

</html>

PDF Output

Example PDF output

pdfviewhelpers's People

Contributors

aimeos avatar derhansen avatar georgringer avatar gernott avatar josefglatz avatar koritnik avatar liayn avatar macjohnny avatar maechler avatar marcharding avatar mk-42 avatar moppiemop avatar morinimoro avatar nhovratov avatar nlehmkuhl avatar physikbuddha avatar rtpast avatar teddytrombone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pdfviewhelpers's Issues

Add possibility to override config settings in Fluid template

It should be possible to overwrite settings defined in plugin.tx_pdfviewhelpers.settings.config within the Fluid template. E.g.

<pdf:document config="{class: 'Vendor\Extension\YourClass'}"></pdf:document>

or

<pdf:config key="class" value="Vendor\Extension\YourClass"></pdf:config>

FPDI importPage does not work with autoPageBreak=1

The fix to this issue should at least be mentioned in the section trouble shooting. Probably we can also include a fix like this for EmptyFPDI:

class YourPDF extends FPDI {
   public function AddPage($orientation = '', $format = '', $rotationOrKeepmargins = false, $tocpage = false)
   {
      parent::AddPage($orientation, $format, $rotationOrKeepmargins, $tocpage);
      
      if ($this->tpl !== 0) {
          $this->useTemplate($this->tpl);
      }
   }
}

It has to be tested whether this works if different pages are imported in one PDF or not. It should also be possible to not import the template anymore, if the PageViewHelper is used without the option importPage. That is not possible with this quick fix. Maybe we could also include an option to make this optional.

Add the possibility to have default settings for more than one headline

e.g.

TypoScript

plugin.tx_pdfviewhelpers.settings {
    headline1 {
        fontSize = 16
        padding {
            top = 6
            right = 0
            bottom = 3
            left = 0
        }   
    }
    headline2 {
        fontSize = 12
        padding {
            top = 4
            right = 0
            bottom = 1
            left = 0
        }   
    }
}

Fluid

<pdf:headline1></headline1>
<pdf:headline2></headline2>

OR

TypoScript

plugin.tx_pdfviewhelpers.settings {
    headline {
        fontSize = 16
        padding {
            top = 6
            right = 0
            bottom = 3
            left = 0
        } 
        types {
            foo {
                fontSize = 20
            }
            bar {
                fontSize = 12
            }
        }
    }
}

Fluid

<pdf:headline type="foo"></headline1>
<pdf:headline type="bar"></headline2>

PHP Warning: Cannot modify header information - headers already sent by ...

any chance to get ride of this?

From the log:
PHP Warning: Cannot modify header information - headers already sent by output started at .../typo3conf/ext/pdfviewhelpers/Classes/ViewHelpers/DocumentViewHelper.php:106) in .../typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php line 3697

TYPO3 Version 7.6.10, PHP Version 7

posX and posY not working

Hi,

great extension. thank you fort that.

I am having a little issue that the posX and posY attribute is being ignored for every element. I think I already found the issue. posX and posY gets set every time even the attribute for it exists:

diff --git a/Classes/ViewHelpers/AbstractContentElementViewHelper.php b/Classes/ViewHelpers/AbstractContentElementViewHelper.php
index 7ee5572..5fb3fbc 100644
--- a/Classes/ViewHelpers/AbstractContentElementViewHelper.php
+++ b/Classes/ViewHelpers/AbstractContentElementViewHelper.php
@@ -59,8 +59,13 @@ abstract class AbstractContentElementViewHelper extends AbstractPDFViewHelper {
                        $this->isValidHeight($this->arguments['height']);
                }
 
-               $this->arguments['posX'] = $this->getPDF()->GetX();
-               $this->arguments['posY'] = $this->getPDF()->GetY();
+               if (is_null($this->arguments['posX'])) {
+                       $this->arguments['posX'] = $this->getPDF()->GetX();
+               }
+
+               if (is_null($this->arguments['posY'])) {
+                       $this->arguments['posY'] = $this->getPDF()->GetY();
+               }
        }
 
        /**

This way a user can put information in the footer without creating a new template file. Is it possible for you to add this fix to your repo? thank you in advance.

best regards
Peter

TYPO3 9 support

Hello, we are developing on TYPO3 9 for a mid term project that will be released after it will become LTS. We need an extension to generate PDF files on the flay. I wanted to ask if you plan to support TYPO3 9 and if you have a timeline for that.

Thanks for your answer and your work.

Improve documentation

  • Fluid template caching on MultiColumnViewHelper
  • Example page structure
  • Example structure
  • ViewHelper documentation (attributes)
  • Available fonts
  • Add custom fonts
  • FPDI in configuration reference
  • Add more examples: Basic, FPDI, Full Feature Show Case

Add PageBreakViewHelper

Add a ViewHelper to add page breaks, that would allow conditional page breaks within the Fluid template.

<pdf:page>
    Lorem

    <f:if condition="{var}">
        <pdf:pageBreak />
    </f:if>

    ipsum
</pdf:page>

Can't add custom font

Hello,

trying to use an imported custom font doesn't work. The view doesn't load and throws this error:

"TCPDF ERROR: Could not include font definition file: foo"

This is my configuration typoscript:

PDFviewhelper settings

plugin.tx_pdfviewhelpers.settings.config.fonts {
addTTFFont {
foo {
path = EXT:pdfviewhelpers/Resources/Public/Examples/FullFeatureShowCase/Roboto.ttf
}
}
}

It appears to work, because using a wrong file path will also throw an error.

No more compatibility with PHP 5.4

Hi,

The last version of the extension is no more compatible with PHP 5.4 because of this line :

$this->configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);

in 5.4 you can use this :

$this->configurationManager = GeneralUtility::makeInstance(\get_class(new \TYPO3\CMS\Extbase\Configuration\ConfigurationManager));

Reagrds,
Florian

Fontsize wrong in pdf:html

Since version 1.5.2 the fontsize of text inside of pdf:html is too small.
Example code of my extension:

<pdf:html>
<table style="font-size:9px;><tr><td>Text</td></tr></table>
</pdf:html>

I need to change the fontsize from 9 to more than 20, to get the same size as with version 1.5.1 and older.

Perhaps this is an TCPDF issue?

ViewHelper to load css styles for HtmlViewHelper

e.g.

<pdf:includeCss src="typo3conf/ext/pdfviewhelpers/Resources/Public/Css/pdf_styles.css" />

or

<pdf:html styles="typo3conf/ext/pdfviewhelpers/Resources/Public/Css/pdf_styles.css">
    <h1>styled html content</h1>
</pdf:html>

Error in create PDF string

Hi Markus and Estaban

Markus, do you remember me from Begasoft?

You two have done a cool modern extension to create PDFs, congratulations!

Unfortunately I found an error when creating a PDF String.

In method DocumentViewHelper::render() for outputDestination = "S", the call:
$this->getPDF()->Output($outputPath, $this->arguments['outputDestination']);
should store the result string and return it from the method.

Would be nice to have fixed for the next release :-)

Have fun
Hanspeter

No content in outputPath!

I upgraded from version 1.x to version 2.0 and did all of the upgrading changes.

<pdf:document sourceFile="fileadmin/template.pdf" outputPath="typo3temp/registration.pdf">

This statement leads to a registration.pdf equal template.pdf. If I use outputDestination="inline" the result has the content of template.pdf inlcuding all pdf:text statements I've set.

Why does registration.pdf don't carry any content? What could be missing?

Warning in TCPDF on PHP 7.1.x

Trying to render content with more than one link in it, runs in a "Illegal string offset 'url'" warning in tcpdf.php, which breaks the PDF rendering. Updating to tecnickcom/TCPDF 6.2.13 solves this problem.

ConfigurationManager not initialized correctly

The configurationManager should be retrieved from the Extbase Object Manager in order to be correctly initialized.

Replace the following line:

$this->configurationManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');

with:

$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');

A possible error resulting from that issue could be:

Fatal error: Call to a member function getConfiguration() on null in /usr/share/typo3/typo3_src-7.6.16/typo3/sysext/extbase/Classes/Configuration/ConfigurationManager.php on line 128

PHP 7.2

Compatibility with PHP 7.2

Problems with Html ViewHelper

I had a very big problem with your Html ViewHelper. When I tried to show some content from my database over a fluid command I got a blank side.

This is my code for the geneartion of the PDF-Document:

{namespace pdf=Bithost\Pdfviewhelpers\ViewHelpers}

<pdf:document outputDestination="I" title="Report">
    <pdf:page autoPageBreak="1">
        <pdf:html>
            <style>
                table {
                    color: #003300;
                    font-size: 8pt;
                    border: 1px solid black;
                }
                th {
                    font-weight: bold;
                    font-size: 8px;
                    text-align: left;
                    border-bottom: #eee 1px solid;
                    background-color: #eee;
                }
                td {
                    border: none;
                }
            </style>
            <f:for each="{uebersicht.fach}" as="fluid">
                <table class="first" cellpadding="2" cellspacing="5">
                    <tr>
                        <th>Fachübersicht</th>
                    </tr>
                    <tr>
                        <td>{uebersicht.fachid}&nbsp;{uebersicht.title}</td>
                    </tr>
                </table>
                <f:for each="{uebersicht.fach}" as="fach">
                    <table class="second" cellpadding="2" cellspacing="5">
                        <tr>
                            <th>Kurze Info</th>
                        </tr>
                        <tr>
                            <td>{fach.title}</td>
                        </tr>
                        <tr>
                            <th>Vielen dank an:</th>
                        </tr>
                        <tr>
                            <td>{fach.author}</td>
                        </tr>
                        <tr>
                            <th>Datum</th>
                        </tr>
                        <tr>
                            <td>{fach.date}</td>
                        </tr>
                        <tr>
                            <th>Eingaben:</th>
                        </tr>
                        <tr>
                            <th><f:format.htmlentitiesDecode value="{fach.content}" /></th>
                        </tr>
                    </table>
                </f:for>
            </f:for>
        </pdf:html>
    </pdf:page>
</pdf:document>

I found out, that the f.format.htmlentitiesDecode is never working. When I delete this code I get some times a text and sometimes no text.
When I activate the header, then I see only the header and no html-content.

I hope you can help me.
Best
Behau

Disable TYPO3 caching by default

Disable caching by default because it makes no sense to save the PDF to the frontend cache. And if the PDF is saved to the filesystem there will be an empty cache entry for this page causing the PDF ViewHelpers not to be executed on a second call.
Add a TypoScript configuration to enable caching.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.