【发布时间】:2014-07-21 22:32:31
【问题描述】:
我正在使用 FPDI 加载 PDF 文件并尝试在模板中放置 PNG 图像。原始文档单位为 mm 和 150ppi。当我将图像设置在坐标 50mm,50mm (50mm = 141,7323 px) 时,图像实际上在 151,7323px 处设置为向右多 10px,底部多 10px。我将边距设置为 0。我将 XY 原点设置为 0,0。我不知道出了什么问题。
// initiate FPDI
$pdf = new FPDI('L','mm');
// get the page count
$pageCount = $pdf->setSourceFile('../lib/handoutv1.pdf');
// iterate through all pages
// import a page
$templateId = $pdf->importPage(1);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
}
// use the imported page
$pdf->useTemplate($templateId);
$pdf->SetMargins(0, 0, 0);
$pdf->SetFont('Helvetica');
$pdf->SetXY(5, 5);
$pdf->Write(8, 'A complete document imported with FPDI');
$pdf->SetXY(0, 0);
$pdf->Image('http://server.com/png.png',50,50,30,30,'PNG');
【问题讨论】:
标签: fpdf