【问题标题】:FPDF coordinates dont fitFPDF 坐标不适合
【发布时间】: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


    【解决方案1】:

    代码看起来没问题。我猜你的图像中有一种边缘会导致这种效果,可能吗?

    【讨论】:

    • 我对@9​​87654321@ 的赌注超过了利润,至少这对我来说是固定的。如您所见,他已经设置了边距:-)
    猜你喜欢
    • 1970-01-01
    • 2021-11-12
    • 2014-01-11
    • 1970-01-01
    • 2012-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-16
    相关资源
    最近更新 更多