我有以下pdflib代码:
$pdf = pdf_new();
pdf_begin_document($pdf, "", "");
pdf_begin_page($pdf, $bleedw,$bleedh);
pdf_arc($pdf,2.63*72,1.13*72,(2*72/2),270,90);
pdf_arc($pdf,.25*72,$bleedh-.25*72,(.25*72/2),90,180);
pdf_arc($pdf,.25*72,.25*72,(.25*72/2),180,270);
pdf_lineto($pdf,2*72/2,$bottom);
pdf_closepath_stroke($pdf);
//output pdf
pdf_end_page($pdf);
pdf_end_document($pdf, "");
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header("Content-disposition: attachment; filename=custom_template_outside.pdf");
header("Content-length: " . strlen($data));
echo $data;
如何将此生成的图形放在现有的pdf文件之上?
答案 0 :(得分:3)
<?php
$pdf = pdf_new();
pdf_begin_document($pdf, "", "");
////////////////
// OPEN PDF DOC
// infilename : input pdf's full path
$doc = pdf_open_pdi_document($pdf, $infilename, "");
if ($doc == -1) {
throw new Exception("Error: " + pdf_get_errmsg());
}
// OPEN PDF PAGE FROM DOC
// pageno : page no i.e 1
$page = pdf_open_pdi_page($doc, $pageno, "");
if ($page == -1) {
throw new Exception("Error: " + pdf_get_errmsg());
}
///////////////
pdf_begin_page($pdf, $bleedw, $bleedh);
//////////////
// out put pdf page
pdf_fit_pdi_page($page, 0, 0, "adjustpage");
pdf_close_pdi_page($page);
/////////////
pdf_arc($pdf, 2.63*72, 1.13*72, (2*72/2), 270, 90);
pdf_arc($pdf, .25*72, $bleedh-.25*72, (.25*72/2), 90, 180);
pdf_arc($pdf, .25*72, .25*72, (.25*72/2), 180, 270);
pdf_lineto($pdf, 2*72/2, $bottom);
pdf_closepath_stroke($pdf);
//output pdf
pdf_end_page($pdf);
pdf_end_document($pdf, "");
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header("Content-disposition: attachment; filename=custom_template_outside.pdf");
header("Content-length: " . strlen($data));
echo $data;