简体   繁体   English

PDFlib将PDF与另一个PDF重叠

[英]PDFlib overlap PDF with another PDF

I am generating a PDF using PDFlib where the user is able to upload images and also PDF to insert into the template. 我正在使用PDFlib生成PDF,用户可以在其中上传图像,也可以将PDF插入模板。

For the image I can simply use 对于图像,我可以简单地使用

$image = $p->load_image("auto", $logo, "");
if ($image == 0) {
   echo ("Error: " . $p->get_errmsg());
   exit(1);
}

// Place logo in pdf
$x = 100;
$y = 100;
$p->fit_image($image, 400, 80, "");
$p->close_image($image);

I am trying to achieve the same to place a PDF. 我试图实现同样的目的来放置PDF。

I know I could just convert the PDF for placement to an image but that's not what I want. 我知道我可以将放置的PDF转换为图像,但这不是我想要的。

How can I place the .pdf inside my PDF? 如何将.pdf放入PDF? Sounds crazy... 听起来很疯狂...

you can do this with the PDFlib Import extension PDI . 您可以使用PDFlib导入扩展名PDI进行此操作 Some of the bundled PDFlib samples, like invoice.php, starter_pdfmerge.php are demonstrating the usage. 一些捆绑的PDFlib示例(例如invoice.php,starter_pdfmerge.php)正在演示用法。

// use errorpolicy exception to throw an exception instead of return 0
$p->set_option("errorpolicy=exception");
$doc = $p->open_pdi_document($logo, "");
// open page $pageno of the document
$page = $p->open_pdi_page($doc, $pageno, "");

// Place logo in pdf
$x = 100;
$y = 100;
$p->fit_pdi_page($page, 400, 80, "");
$p->close_pdi_page($page);
$p->close_pdi_document($doc);

you find further samples in the PDFlib cookbook - > PDF Import . 您可以在PDFlib食谱-> PDF Import中找到更多示例。 (also as PHP) (也作为PHP)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM