Search code examples
zend-frameworkpdfpngemail-attachmentszend-mail

Zend Mail - Pdf Attachment - imbedded png gets scrambled


I've got my Zend_Mail setup and working fine, but the png images in my pdf attachment get scrambled.

This is the bit responsible for the attachment:

$filecontents = file_get_contents($attachment);

$att = $this->mail->createAttachment($filecontents);
$att->disposition = 'Zend_Mime::DISPOSITION_INLINE';
$att->encoding = 'Zend_Mime::ENCODING_BASE64';
$att->filename = 'result.pdf';
$att->type = 'application/pdf';

The Pdf is created with Zend_Pdf

The PNG is added like this:

$image = Zend_Pdf_Image::imageWithPath("path/to/png.png");
$this->page->drawImage($image, $left, $bottom, $right, $top);

Any ideas?

Thanks in advance!

Peter


Solution

  • Do you actually want the PDF to be inline in the email? I don't think email clients even support that. Try Zend_Mime::DISPOSITION_ATTACHMENT.

    Also, the constants should not be in quotes. It's just $at->disposition = Zend_Mime::DISPOSITION_ATTACHEMENT.