0
感谢您花一点时间阅读本文。ZendPdf放置镜像效果的图像
我写上ZendPdf飞一个PDF文件,但在当下的图片添加到其显示镜像PDF:
这里是效果更好的理解: http://snag.gy/ZYbWp.jpg
原始图像很好。
有人能告诉我为什么图像是镜像的,我怎么能把它渲染成原始图像?
我在这里粘贴它生成pdf的整个操作。
public function createPdfAction()
{
$country = $this->params()->fromRoute('lang', null);
$pdf = new \ZendPdf\PdfDocument();
// Add new page generated by ZendPdf\Pdf object
// (page is attached to the specified the document)
$pdf->pages[] = ($page1 = $pdf->newPage('A4'));
$width = $page1->getWidth();
$height = $page1->getHeight();
$imageFile = dirname(__FILE__) . '/../../../../../html/img/site/logo_peug_scooter.jpg';
if (!isset($pdf->imageCache[$imageFile]))
{
try {
// Create new image object
//$stampImage = ZendPdf\Image::imageWithPath($imageFile);
$pdf->imageCache[$imageFile] = ZendPdf\Image::imageWithPath($imageFile);
} catch (ZendPdf\Exception $e) {
// Example of operating with image loading exceptions.
if ($e->getMessage() != 'Image extension is not installed.' &&
$e->getMessage() != 'JPG support is not configured properly.') {
throw $e;
}
$pdf->imageCache[$imageFile] = null;
}
}
if (null != $pdf->imageCache[$imageFile]) {
$page1->drawImage($pdf->imageCache[$imageFile], 50, $height, 50 + 220, $height - 70);
}
// Create new font
$font = ZendPdf\Font::fontWithPath(dirname(__DIR__) . '/../../../../html/fonts/peugeot_style-webfont.ttf');
// Apply font and draw text
$page1->setFont($font, 16)
->setFillColor(ZendPdf\Color\Html::color('#0b2333'))
->drawText('DJANGO', 50, $height - 18 - 18 - 50);
if ('uk' == $country) {
$locale = 'en_GB'; //. strtoupper($country);
} else {
$locale = $country . '_' . strtoupper($country);
}
setlocale(LC_MONETARY, $locale);
$price = money_format('%i', 2660);
$font = ZendPdf\Font::fontWithPath(dirname(__DIR__) . '/../../../../html/fonts/peugeot_normal-webfont.ttf');
// Apply font and draw text
$page1->setFont($font, 16)
->setFillColor(ZendPdf\Color\Html::color('#0b2333'))
->drawText($price, 447, $height - 18 - 18 - 50);
$pdf->save('/tmp/pdfs/sample2.pdf');
$this->layout('layout/empty');
$viewModel = new ViewModel();
$viewModel->setTerminal(true);
return $viewModel;
}
我会很感激任何指导。
谢谢。
谢谢,我已经知道了。 – manou
我遇到了问题,我自己寻找答案。在我想通了之后,我将它发布给未来的访问者。没想到你会等7个月。 :-) –
是的,谢谢你帮忙解决问题,因为它可能是。我忘了回来重玩自己。当我提出问题时,我会用我的所有研究发表评论。 – manou