Welcome Guest Search | Active Topics | Sign In | Register

EO.Pdf Mail Attachments Options
Urban Global
Posted: Tuesday, July 14, 2015 9:40:54 PM
Rank: Newbie
Groups: Member

Joined: 7/14/2015
Posts: 2
Hi

We're currently migrating our application to use EO.Pdf and can successfully output .PDF documents via OutputStream. The problem I'm having is converting the same Html into Email PDF attachments. The result is an empty file/attachment and an error message of "could not open ... because it is either not a supported file type or because the file has been damaged..." when you try to open it with Adobe.

This is the basic code that creates the attachment. Can you please correct me where I'm wrong or suggest an alternative method.

Code: C#
Stream fileStream = new MemoryStream();
string fileContent = "HTML content";

HtmlToPdf.ConvertHtml(fileContent, fileStream, new HtmlToPdfOptions()
{
    PageSize = PdfPageSizes.A4, OutputArea = new RectangleF(0F, 0F, 8.27F, 11.69F)
});

return new Attachment(fileStream, "fileNameHere", MediaTypeNames.Application.Pdf);
eo_support
Posted: Tuesday, July 14, 2015 10:33:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

ConvertHtml will place the current position to the end of the MemoryStream. You need to call Seek to seek to the beginning of MemoryStream before you pass it to the Attachment.

Thanks!
Urban Global
Posted: Tuesday, July 14, 2015 10:48:22 PM
Rank: Newbie
Groups: Member

Joined: 7/14/2015
Posts: 2
Hi

Thank you, that worked.
eo_support
Posted: Wednesday, July 15, 2015 10:09:51 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Great. Please feel free to let us know if you have any more questions.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.