Re: PDF file download question.

  •  03-06-2008, 6:00 PM

    Re: PDF file download question.

    Here's my code.  GetHTMLForm is a function call to a routine that gets the HTML to convert so you can replace that with your stirng.
     

    // here is where we'll get the HTML for the form

    string strFormContent = GetHTMLForm(pnlForm);

    Stream sPDFForm = new MemoryStream();

    try

    {

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

    objConverter.Save(sPDFForm);

    sPDFForm.Position = 0;

    }

    catch (Exception ex)

    {

    // We bombed creating PDF, move on

    lblMessage.Text += "Error generating the PDF.<br/>Exception Details: " + ex.Message;

    }

     

    Response.ContentType = "application / pdf";

    Response.AddHeader("Content-Disposition", "attachment; filename = somefile.pdf");

    Byte[] Holder = new Byte[sPDFForm.Length];

    sPDFForm.Read(Holder, 0, Convert.ToInt32(sPDFForm.Length));

    Response.BinaryWrite(Holder);

    Response.End();

    sPDFForm.Close();

View Complete Thread