【问题标题】:PDF generation using dompdf使用 dompdf 生成 PDF
【发布时间】:2012-06-06 09:10:57
【问题描述】:

使用 dompdf 我生成 pdf 文件。我成功生成它。 但是当我在 Foxit 阅读器中打开它时生成它之后,它在 51.79% 模式下打开的尺寸非常小。当我选择“适合宽度”或 125% 时,它会正确显示。 当我默认打开 pdf 时,它会打开 125% 模式吗?

我使用了以下功能:

function pdf_create($html, $filename)
    {
        ini_set("memory_limit", "50M");
        //define pdf store path
        $invoice_pdf_path = ABSOLUTE_PATH;
        require_once("dompdf/dompdf_config.inc.php");
        $dompdf = new DOMPDF();
        $dompdf->load_html($html);
        $dompdf->set_paper("a4", "portrait");
        $dompdf->render();
        //$dompdf->stream("abc_out.pdf");
        $pdf = $dompdf->output();
        @file_put_contents($invoice_pdf_path . $filename . ".pdf", $pdf);

    }

【问题讨论】:

    标签: pdf-generation dompdf


    【解决方案1】:

    使用 dompdf 0.6 beta,您可以通过在 HTML 源代码中添加元标记来设置 PDF 的默认视图:

    <meta name="dompdf.view" content="FitH" />
    

    可能的值为“XYZ”、“Fit”、“FitH”、“FitV”、“FitR”、“FitB”、“FitBH”、“FitBV”,描述为here

    【讨论】:

    • @user1429954 试试 $dompdf->set_default_view('FitH',array());
    猜你喜欢
    • 2017-08-14
    • 2015-10-30
    • 2020-07-12
    • 1970-01-01
    • 2012-09-13
    • 2011-06-27
    • 2022-01-03
    • 1970-01-01
    相关资源
    最近更新 更多