Re: HTML2PDF conversion issue

  •  02-20-2008, 7:59 PM

    Re: HTML2PDF conversion issue

    And I have come full circle and answered my own question after banging my head for hours.... 
     
    For those who care, the final code that I got to work was:
     
    -------------------------------------------------------------------------------------------

    CuteEditor.Convertor.PDF.
    HTML2PDF objConverter = new CuteEditor.Convertor.PDF.HTML2PDF(strFormContent);

    Stream sPDFForm = new MemoryStream();

    objConverter.RenderSinglePageContent = false;

    objConverter.Render();

    objConverter.Save(sPDFForm);

    sPDFForm.Position = 0;

    System.Net.Mail.Attachment objAttachment = new System.Net.Mail.Attachment(sPDFForm, objContent.ContentHeader + ".pdf");

     

    objMessage.Attachments.Add(objAttachment);

    ------------------------------------------------------------------------------------------------------------------------------------------
    What I didn't catch was that after calling the 'save' method of the HTML2PDF object, the stream position is at the end instead of the beginning.  This explains why I got zero byte files.  Once I added the line:
     
    sPDFForm.Position = 0;
     
    to set the position back to the beginning of the stream, all was working.
     
    Hope this helps someone out there!
     
    Adam (not that Adam!)
     
     
View Complete Thread