function file_get_html($url, $use_include_path = false, $context = null, $offset = -1, $maxLen = -1, $lowercase = true, $forceTagsClosed = true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = DEFAULT_BR_TEXT)
{
    // We DO force the tags to be terminated.
    $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $defaultBRText);
    // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
    $contents = file_get_contents($url, $use_include_path, $context, $offset);
    // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
    //    $contents = retrieve_url_contents($url);
    if (empty($contents)) {
        return false;
    }
    $contents = compressHTML($contents);
    // The second parameter can force the selectors to all be lowercase.
    $dom->load($contents, $lowercase, $stripRN);
    return $dom;
}
Exemple #2
0
/**
 * Procedural way to add a page to a TCPDF object
 *
 * @param TCPDF $pdf
 * @param String $html
 */
function tcpdf_addPage(TCPDF &$pdf, $html)
{
    // Add a page
    // This method has several options, check the source code documentation for more information.
    // Print text using writeHTML()
    $pdf->AddPage();
    $html = compressHTML($html);
    $html = str_replace(array('<head>', '<body>', '</head>', '</body>', '</html>', '<html>', '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">', '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'), '', $html);
    $pdf->writeHTML($html, true, false, true, false);
}