pdf_generator2 in tt_news single view
With pdf_generator2, we can produce pdf format of our web page. To use this extension in tt_news single view, we need to setup the typoscript configuration. This typoscript example will show the pdf link beside the tt_news single view title and put the web url as header and page number and date as footer in the pdf document.
1. Put this definition in constants section of the main template:
pdf_generator2 {
size = A4
top = 15
bottom = 15
left = 15
right = 15
cssmedia = print
max_execution_time = 10000
renderfields = 1
string_search1 = /*<![CDATA[*/
string_replace1 = /* <![CDATA[ */
string_search2 = /*]]>*/
string_replace2 = /* ]]> */
string_search2 = <body>
string_replace2 = <body> <!-- PDF VERSION -->
}
remember that we need to use cssmedia = print to hide the pdf link in the pdf version.
3. Content of htmltopdf.html:
4. Content of html2pdf.css:
After all set, you will have the pdf link in the tt_news single view title.
1. Put this definition in constants section of the main template:
pdf_generator2 {
size = A4
top = 15
bottom = 15
left = 15
right = 15
cssmedia = print
max_execution_time = 10000
renderfields = 1
string_search1 = /*<![CDATA[*/
string_replace1 = /* <![CDATA[ */
string_search2 = /*]]>*/
string_replace2 = /* ]]> */
string_search2 = <body>
string_replace2 = <body> <!-- PDF VERSION -->
}
remember that we need to use cssmedia = print to hide the pdf link in the pdf version.
2. Put this typoscript in setup section of the main template:
# This is for the pdf link
temp.PDF = IMAGE
temp.PDF {
file = fileadmin/images/file_pdf.png
stdWrap.postUserFunc = tx_pdfgenerator2->makePdfLink
stdWrap.postUserFunc.target = _blank
stdWrap.postUserFunc.no_user_int = 0
stdWrap.postUserFunc.ATagParams = id = "tohide"
}
temp.PDF {
file = fileadmin/images/file_pdf.png
stdWrap.postUserFunc = tx_pdfgenerator2->makePdfLink
stdWrap.postUserFunc.target = _blank
stdWrap.postUserFunc.no_user_int = 0
stdWrap.postUserFunc.ATagParams = id = "tohide"
}
#This is to put the web url in the pdf header
temp.pu = TEXT
temp.pu.data = getIndpEnv:TYPO3_REQUEST_URL
temp.pu.data = getIndpEnv:TYPO3_REQUEST_URL
#This is to put the header and footer in the pdf document and
# include the css from the current working template
# include the css from the current working template
pdf_generator {
stylesheet = fileadmin/html2pdf.css
includeCSS < page.includeCSS
10 = TEMPLATE
10.template = FILE
10.template.file = fileadmin/htmltopdf.html
10.marks.url < temp.pu
}
stylesheet = fileadmin/html2pdf.css
includeCSS < page.includeCSS
10 = TEMPLATE
10.template = FILE
10.template.file = fileadmin/htmltopdf.html
10.marks.url < temp.pu
}
#This is to put the pdf link beside the tt_news single view title
temp.test = COA
temp.test {
10 = TEXT
10.field = title
20 < temp.PDF
}
temp.test {
10 = TEXT
10.field = title
20 < temp.PDF
}
#Finally activate the modified tt_news single view title
plugin.tt_news{
displaySingle.title_stdWrap.cObject < temp.test
}
}
<!--###DOCUMENT_BODY### start -->
<div style="position: fixed; top: -10mm; left: 0;">###url###</div>
<div style="position: fixed; bottom: -10mm; right: 0;">
page ##PAGE## of ##PAGES## , date: ##TIMESTAMP##
</div>
<!--###DOCUMENT_BODY### stop -->
<div style="position: fixed; top: -10mm; left: 0;">###url###</div>
<div style="position: fixed; bottom: -10mm; right: 0;">
page ##PAGE## of ##PAGES## , date: ##TIMESTAMP##
</div>
<!--###DOCUMENT_BODY### stop -->
@media print {
#tohide { display:none; }
}
#tohide { display:none; }
}
Comments