大内容没有移到dompdf

时间:2016-06-21 15:19:49

标签: php dompdf

我正在从html生成pdf。问题是,如果有任何大的内容,那么它没有正确显示。首先出现一个空白页面,然后内容重叠页脚,但不显示全文。其余内容正在隐藏,而不是移动到下一页。我试过了page-break-after:always; page-break-inside:avoid;

关于这个问题的任何想法?

检查以下代码: -

$html = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ 

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry

ÆØÅ  ÆØÅ  ÆØÅ ÆØÅ ";

pdfGenerate($html);

function pdfGenerate($html="")
{
    require_once("dompdf/dompdf_config.inc.php");
    $dompdf = new DOMPDF();


    $dompdf->load_html($html);
    $dompdf->render();
    $canvas = $dompdf->get_canvas();
    $font = Font_Metrics::get_font("Arial");
    $canvas->page_text(510, 775, "{PAGE_NUM} av {PAGE_COUNT}",
                   $font, 10, array(0,0,0));
    $dompdf->stream("sample.pdf");
}

1 个答案:

答案 0 :(得分:0)

对我来说,我修改了垃圾代码,但实际上效果很好。 dompdf生成一个2页的pdf

$dompdf = new \Dompdf\Dompdf();
$dompdf->load_html($html);
$dompdf->render();
$canvas = $dompdf->get_canvas();
$options = new \Dompdf\Options();
$fontMetrics = new Dompdf\FontMetrics($canvas,$options);
$font = $fontMetrics->getFont('Arial');
$canvas->page_text(510, 775, "{PAGE_NUM} av {PAGE_COUNT}",
               $font, 10, array(0,0,0));
$dompdf->stream("sample.pdf");

一个重要的事情是你的例子是纯文本,我认为使用html(一个完整的html页面)更准确