|
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);
|
|
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!
|
|
Rank: Newbie Groups: Member
Joined: 7/14/2015 Posts: 2
|
Hi
Thank you, that worked.
|
|
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.
|
|