【问题标题】:Printing a pdf as an image inside of a pdf将 pdf 打印为 pdf 内的图像
【发布时间】:2014-05-29 22:22:38
【问题描述】:

我正在创建一个网络应用程序并使用一个 php FPDF 脚本来创建和打印一个 pdf。这也会在上传到应用程序的 pdf 图像上打印出来,这没问题。但是,它需要为上传的 pdf 做同样的事情,这就是我的问题所在。如何使用 fpdf 将 pdf 打印为 pdf 内的图像?

我听说过 imageMagick,但我不认为这是一个选择,因为它是一个软件,我不知道我会在哪里运行它。

【问题讨论】:

    标签: pdf imagemagick fpdf


    【解决方案1】:

    您可以使用FPDI 导入现有 PDF 文档的页面并将其与 FPDF 一起放置到新创建的页面上:

    <?php
    require_once('fpdf.php');
    require_once('fpdi.php');
    
    $pdf = new FPDI();
    
    // load the document and get the total page count
    $pageCount = $pdf->setSourceFile("the/document/you/want/to/import/a/page/from.pdf");
    // import the first page
    $tplIdx = $pdf->importPage(1);
    
    // add a page
    $pdf->AddPage();
    // use the imported page on x=10, y=10 and a width of 90
    $pdf->useTemplate($tplIdx, 10, 10, 90);
    // output the PDF document
    $pdf->Output();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-09
      • 2015-08-21
      • 1970-01-01
      • 2018-12-03
      • 2011-09-24
      • 2021-02-09
      • 1970-01-01
      相关资源
      最近更新 更多