- Posts: 5
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
span.sectionTitle {font-size:18pt; font-weight:bold; page-break-before:always;}
I force page break in tcPDF in a plugin with:adamzammit wrote: ////
queXML PDF uses TCPDF to generate the PDF document. Some CSS styling will work, but not all. Also some (such as this page break CSS) may have unexpected results due to the way the queXML PDF system generates the PDF file.
....
<br pagebreak="true" />
$oPDF = new pdfReport(); // Bad hacking to clean HTML code but leave page break $pdfSpecific=array('<br pagebreak="true" />','<br pagebreak="true"/>','<br pagebreak="true">','<page>','</page>'); $pdfReplaced=array('<span>br pagebreak="true"</span>','<span>br pagebreak="true"</span>','<span>br pagebreak="true"</span>','<span>page</span>','<span>/page</span>'); $sText=str_replace($pdfSpecific, $pdfReplaced, $sText); if(function_exists ("tidy_parse_string")) // Call to undefined function tidy_parse_string() in ./application/third_party/tcpdf/include/tcpdf_static.php on line 2099 { $tidy_options = array ( 'clean' => 1, 'drop-empty-paras' => 0, 'drop-proprietary-attributes' => 0, 'fix-backslash' => 1, 'hide-comments' => 1, 'join-styles' => 1, 'lower-literals' => 1, 'merge-divs' => 1, 'merge-spans' => 1, 'output-xhtml' => 1, 'word-2000' => 0, 'wrap' => 0, 'output-bom' => 0, 'char-encoding' => 'utf8', 'input-encoding' => 'utf8', 'output-encoding' => 'utf8' );// Fix UTF8 and <br preakpage="true" /> $sText=$oPDF->fixHTMLCode($sText,$sCssContent,'',$tidy_options); } else { // TODO : Find the good way to use pagebreak="true", verify i page is used in tcpdf // ALT : explode/implode $oPurifier = new CHtmlPurifier(); $oPurifier->options = array( 'AutoFormat.RemoveEmpty'=>false, 'Core.NormalizeNewlines'=>false, 'CSS.AllowTricky'=>true, // Allow display:none; (and other) 'CSS.Trusted' => true, 'Attr.EnableID'=>true, // Allow to set id 'Attr.AllowedFrameTargets'=>array('_blank','_self'), 'URI.AllowedSchemes'=>array( 'http' => true, 'https' => true, 'mailto' => true, 'ftp' => true, 'nntp' => true, 'news' => true, ) ); $sText=$oPurifier->purify($sText); } $sText=str_replace($pdfReplaced, $pdfSpecific, $sText);