コード例 #1
0
 function convert($content)
 {
     $config = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ods_html2pdf']);
     if ($config['wkhtmltopdf_bin']) {
         if ($config['debug']) {
             $htmlfile = PATH_site . 'typo3temp/tx_odshtml2pdf/' . $GLOBALS['TSFE']->id . '.html';
             file_put_contents($htmlfile, $content);
         }
         $cmd = $config['prepend_bin'] . ' ' . $config['wkhtmltopdf_bin'] . ' ' . $config['wkhtmltopdf_opt'] . ' - -';
         $output = explode('%PDF', tx_odshtml2pdf::shell($cmd, $content), 2);
         if (isset($output[1])) {
             $output[1] = '%PDF' . $output[1];
         }
         return $output;
     }
 }
コード例 #2
0
ファイル: gen_pdf.php プロジェクト: bobosch/ods_html2pdf
    $GLOBALS['TT']->pull();
    $GLOBALS['TSFE']->INTincScript();
    $GLOBALS['TT']->pull();
}
//---------------------------- end Handle UserInt Objects --------------
//---------------------------- make links absolute --------------
function fix_links_callback($matches)
{
    return $matches[1] . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($matches[2]) . $matches[3];
}
$GLOBALS['TSFE']->content = preg_replace_callback('/(<a [^>]*href=\\")(?!#)(.*?)(\\")/', 'fix_links_callback', $GLOBALS['TSFE']->content);
$GLOBALS['TSFE']->content = preg_replace_callback('/(<form [^>]*action=\\")(?!#)(.*?)(\\")/', 'fix_links_callback', $GLOBALS['TSFE']->content);
$GLOBALS['TSFE']->content = preg_replace_callback('/(<img [^>]*src=\\")(?!#)(.*?)(\\")/', 'fix_links_callback', $GLOBALS['TSFE']->content);
$GLOBALS['TSFE']->content = preg_replace_callback('/(<link [^>]*href=\\")(?!#)(.*?)(\\")/', 'fix_links_callback', $GLOBALS['TSFE']->content);
//---------------------------- end make links absolute --------------
$output = tx_odshtml2pdf::convert($GLOBALS['TSFE']->content);
if ($output[1]) {
    header('Content-type: application/pdf');
    $GLOBALS['TSFE']->content = $output[1];
} else {
    // don't cache errors
    $GLOBALS['TSFE']->set_no_cache();
    $GLOBALS['TSFE']->content = '<html><head><title>wkhtmltopdf problem</title></head><body><h1>wkhtmltopdf problem:</h1>';
    if ($output[0]) {
        $GLOBALS['TSFE']->content .= '<p>wkhtmltopdf produced the following errors:</p>';
        $GLOBALS['TSFE']->content .= '<pre>' . htmlentities($output[0]) . '</pre>';
    } else {
        $GLOBALS['TSFE']->content .= '<p>wkhtmltopdf produced no pdf-output.</p>';
    }
    $GLOBALS['TSFE']->content .= '</body></html>';
}