我面临着一个问题createAttachment方法。这种方法连接的PDF,但PDF格式不公开,其大小为零KB。
$html .= "
<html>
<head>
</head>
<body>
Test pdf
</body>
</html>";
$attachment = $emailTemp->getMail()->createAttachment($html);
$attachment->type = 'application/pdf';
$attachment->filename = 'test.pdf';
$attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT;
$attachment->encoding = Zend_Mime::ENCODING_BASE64;
$emailTemp->send($useremail,$Username,$emailTempVariables);
请帮我尽快。这里Magento有什么问题?我想与在Magento自定义HTML附件中的PDF。
首先,你必须创建一个PDF文件,您可以用下面的代码创建pdf文件,推荐代码只是为了创建示例PDF文件。你可以改变它按您的要求。
$pdf = new Zend_Pdf();
$page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4);
//var_dump($page);
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
define('FONT_SIZE' , 12);
define('MARGIN_LEFT' , 40);
define('MARGIN_TOP' , 40);
define('COL_WIDTH' , 100);
define('COL_LEFT_MARGIN', 10);
define('COL_SEPARATOR' , '|');
define('ROW_HEIGHT' , 20);
$row = 1;
$x = MARGIN_LEFT;
$y = MARGIN_TOP;
$page->setFont($font, FONT_SIZE);
$page->drawText('ABCD', $x, $page->getHeight() - $y);
$x += COL_WIDTH;
$x += COL_LEFT_MARGIN;
$x = MARGIN_LEFT;
$y += ROW_HEIGHT;
$pdf->pages[] = $page;
$pdf->save('data.pdf', true);
生成PDF文件后,尝试用已创建正确的PDF文件,您的附件代码。
http://www.maijindou.com.cn/