Zend_Pdf如何设置595x842图像作为A4 pdf的背景
我有一张尺寸为 595x842px 的图像,我想使用该图像作为 pdf 页面的背景。我想让它填满整个背景。我怎样才能做到这一点?我现在有这个:
<?php
error_reporting(E_ALL);
set_include_path(get_include_path() . PATH_SEPARATOR . 'd:/data/o');
// Load Zend_Pdf class
include 'Zend/Pdf.php';
// Create new PDF
$pdf = new Zend_Pdf();
// Add new page to the document
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
// Load image
$image = Zend_Pdf_Image::imageWithPath('bg.jpg');
// Draw image
$page->drawImage($image, 0, 0, 842, 595);
// Save document as a new file or rewrite existing document
$pdf->save('test.pdf');
echo 1;
?>
但是生成的pdf很糟糕,背景图像非常模糊并且没有填充整个背景。
I have an image with 595x842px dimensions, I would like to use the image as a background for a page in pdf. I want it to fill the whole background. How can I do that? I have this now:
<?php
error_reporting(E_ALL);
set_include_path(get_include_path() . PATH_SEPARATOR . 'd:/data/o');
// Load Zend_Pdf class
include 'Zend/Pdf.php';
// Create new PDF
$pdf = new Zend_Pdf();
// Add new page to the document
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
// Load image
$image = Zend_Pdf_Image::imageWithPath('bg.jpg');
// Draw image
$page->drawImage($image, 0, 0, 842, 595);
// Save document as a new file or rewrite existing document
$pdf->save('test.pdf');
echo 1;
?>
But the resulting pdf is terrbile, the background images is very blurry and doesn't fill the whole background.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已解决:
我真的很笨:P
通过制作更高分辨率的图像解决了图像模糊的问题。
SOLVED:
I'm really dumb :P
The issue with blurred image was solved by making a greater resolution image.