Coder Social home page Coder Social logo

bithost-gmbh / pdfviewhelpers Goto Github PK

View Code? Open in Web Editor NEW
43.0 3.0 19.0 55.17 MB

TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.

License: GNU General Public License v3.0

PHP 81.15% HTML 18.59% Shell 0.02% CSS 0.24%
typo3 viewhelper fluid fluid-viewhelpers tcpdf fpdi typo3-cms-extension pdf pdf-generation viewhelpers

pdfviewhelpers's People

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

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

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>

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

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

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

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.

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

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?

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>

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>

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>

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?

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.

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.

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

PHP 7.2

Compatibility with PHP 7.2

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.

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.

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.