Install additional fonts for PDFlib
If you want to use PDFlib you'll have to install additional fonts. This is most easily done by installing the pdf_generator2_fonts extension. They are packaged separately from the rest to keep the extension sizes manageable.
Update .htaccess
You will need to update your .htaccess if you want the links to your PDF files be static (i.e. <alias.pdf>). This change is necessary to forward all requests to /<...>.PDF files to typo3's index.php.
ErrorDocument 404 /error.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^typo3$ /typo3/index_re.php
RewriteRule ^[^/]*\.html$ index.php
RewriteRule ^[^/]*\.pdf$ index.php
Available Options
simulateStaticPdf
This parameter will define whether the link to the PDF files will be a static one (i.e. <alias>.pdf) or dynamic ones (index.php?id=12&type=123). If you enable this you will need to update your .htaccess.
Disable gzip compression
If this parameter is set and you have gzip-compression turned on for the Frontend ( [FE][compressionLevel] in the installation tool) the generated PDF's will not be handled by the additional gzip-compression. It is highly recomended to leave this parameter at default (on) since PDF-files incorporate their own compression and you will only gain little additional compression. Additionally you may get problems with browsers that pass the stream to acrobat without decompressing it (e.g. Netscape 4.08-).
typeID
This parameter defines the typeId that is used for the extension. Normally you will not need to change it.
Add a link in your Typoscript Template using makePdfLink
To add the a link to the PDF page you can wrap any content element in a link using stdwrap.postUserFunc. The following code gives some examples:
[...]
100 = IMAGE
100.file = fileadmin/pdf_link.gif
100.stdWrap.postUserFunc = tx_pdfgenerator2->makePdfLink
[...]
[...]
110 = TEXT
110.value = printable version
110.postUserFunc = tx_pdfgenerator2->makePdfLink
110.postUserFunc.target = _blank
[...]
[...]
temp.PDF = TEXT
temp.PDF.value = pdf
temp.PDF.postUserFunc = tx_pdfgenerator2->makePdfLink
temp.PDF.postUserFunc.include_post_vars = 1
page.120 < temp.PRINT
[...]
If you use the Template Auto-Parser extension and you want to put the link somewhere on your page, you may need to put it in a COA with another element. If you want to place it below the content for example you would change
subparts.content < styles.content.get
to something like
subparts.content = COA
subparts.content {
10 = CONTENT
10 < styles.content.get
20 < temp.PDF
}
and define temp.PDF like above.
Please note that the link will be generated as a USER_INT object by default, i.e. that the link will be generated after the page has been pulled from the cache. If you want to go for maximum performance you can disable that with the parameter postUserFunc.no_user_int = 1 which will generate and cache the link. This is only recommended if you are sure that there are no USER_INT objects on the page that set POST or GET parameters. If you don't understand what i'm writing about leave it at default.
Add a link in your Typoscript Template using openPdfLink
Altenatively you can also use the function tx_pdfgenerator2->openPdfLink which will generate the opening tag for the link. You will need to generate the closing </a> tag yourself´. Example:
page.36= USER_INT
page.36.userFunc = tx_pdfgenerator2->openPdfLink
page.37=TEXT
page.37.value = Link to PDF
page.38=HTML
page.38.value = </a>
Add a link in your Typoscript Template using getPdfTarget
If you just need the target of the pdf link you can use the function getPdfTarget. Amongst other things this can be useful with templavoila. Example:
lib.pdflink = USER_INT
lib.pdflink.userFunc = tx_pdfgenerator2->getPdfTarget
lib.pdflink.userFunc.include_post_vars = 1
Customizing the PDF-Page via Typoscript
The PDF is rendered based on a very simple template. You can easily update the pdf_generator page object to contain additional information or content elements on every PDF page. One especially interesting use is to add special HTML comments to control the behavior of the html2pdf conversion. See the html2pdf documentation (on http://www.tufat.com/docs/html2ps/index.html) for details. A lot of parameters can be set via the Constant Editor (see next chapter).
You don't have to put any of the following lines into your template, they are already there. They are noted here just for reference purposes.
pdf_generator = PAGEpdf_generator { typeNum = {$extension.pdf_generator.typeNum} config.pageGenScript = EXT:pdf_generator/gen_pdf.php config.admPanel = 0 config.xhtml_cleaning = 0 config.USERNAME_substToken = config.ftu = 0 config.disableCharsetHeader = 1 config.prefixLocalAnchors = 0 50 = CONTENT 50 < styles.content.get}