tcpdf - 背景图片 - CakePdf [英] tcpdf - background image - CakePdf
问题描述
我正在尝试使用CakePdf和TcPdf引擎使用背景图片设置pdf生成。我已经设法使用以下设置获得图像的背景:
I am trying to setup pdf generation with a background image using CakePdf and the TcPdf engine. I have managed to get the image onto the background using the following settings:
// set background image
$img_file = APP . 'webroot/img/BC_Letterhead.jpg';
$TCPDF->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
问题是图像似乎覆盖了整个背景。它似乎是大约1英寸短的右边和大约2英寸短的页面的底部。我使用的图片尺寸正确(我已仔细检查过)
The problem is the image does seem to cover the full background. It seems to be about 1 inch short to the right and about 2 inches short of the bottom of the page. The image I am using is the correct size (I double checked it)
这可能是保证金问题或类似问题吗?
Could this be a margin issue or similar?
感谢
推荐答案
我最终得到这个工作或多或少与下面的代码。唯一的问题是我仍然有大约1厘米的底部没有背景图像覆盖它,宽度很好。
I ended up getting this to work more or less with the following code. The only issue is I still have about 1cm at the bottom without the background image covering it, the width is fine.
// -- SET BACKGROUND IMAGE ------------------------------>
$TCPDF->SetFooterMargin(0);
// get the current page break margin
$bMargin = $TCPDF->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $TCPDF->getAutoPageBreak();
// disable auto-page-break
$TCPDF->SetAutoPageBreak(true, 0);
// set background image
$img_file = APP . 'webroot/img/BC_Letterhead.jpg';
$TCPDF->Image($img_file, 0, 0, 225, 305, '', '', '', false, 300, '', false, false, 0);
// set the starting point for the page content
$TCPDF->setPageMark();
$TCPDF->setPrintFooter(false);
// END BACKGROUND MODS -------------------------------->
这篇关于tcpdf - 背景图片 - CakePdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!