Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

1.4. Internals

The extension consists of two php classes and one php script.

gen_pdf.php

This is the main script that generates the PDF file. This is done by calling the original pagegen script and then converting the HTML to PDF using the HTMLDOC program. The generated PDF is then returned to typo3 to be cached for subsequent requests. This script also “fixes” the following issues with the generated HTML:

  1. Sometimes the RTE generates <P> tags within <PRE> tags. They are removed

  2. When using buletted lists the output is theoretically correct but looks quite ugly (the dots are quite a bit above the text line. By changing the alignment of the images to left they look much better.

class.tx_pdfgenerator.php

This class contains the makePdfLink function that is used to generate the link to the PDF file. It takes the current page id and  all attached GET parameters and creates a new link using these values. If the simulateStaticPdf option is set these links will be named <alias>.pdf?<additional parameters>. if not they will be called index.php?id=<id>&type=<pdf_type>&<additional parameters>.

class.ux_tslib_fe.php

This class overrides the core tslib_fe class. Two functions are overridden in typo3 <3.7. In typo3 3.7 and above callbacks are used instead:

checkAlternativeIdMethods

This change will check for a “.pdf” file ending and automatically generate the pageType for the PDF page (default:123)

processOutput

This change will check if a PDF file is currently generated and will add the additionally needed headers then. These include

  1. Content-Type and Content-Dispositionsee Reference for postUserFunc = tx_pdfgenerator->makePdfLink

  2. Cache-control: private, Connection: Keep-AliveThese are need for Internet Explorer to allow downloading of the file  and to avoid IE requesting it twice.

  3. Content-Length: <calculated length>

    This is also needed to avoid the need to press Refresh on IE when working with small PDF files.

Additionally the gzip compression is turned off here by setting the ['FE']['compressionlevel'] to ''.