Re: Convert HTML to PDF creates damaged PDF

  •  12-06-2007, 1:22 PM

    Re: Convert HTML to PDF creates damaged PDF

    Hi Adam,
     
    The code in that thread is practically identical to mine. However, I have reworked my code to be in line with that thread and it makes no difference.
     
    For the "simple" piece of text "Hello Adam", the pdf is written, but Adobe complains that it is damaged. For the more complicated version of the text (the table), it just comes out as a lrge "blob" as it did before.
     
    Here is my modified code:
     

    string docName = "Test.pdf";

    string tableDef = "Hello Adam";

    MemoryStream x = new MemoryStream();

    string t = "<html><body>" + tableDef + "</body></html>";

    CuteEditor.Convertor.PDF.HTML2PDF html2pdf = new CuteEditor.Convertor.PDF.HTML2PDF(Server.HtmlDecode(t));

    html2pdf.Render();

    html2pdf.Save(x);

     

    HttpResponse resp = HttpContext.Current.Response;

    resp.ContentType = "application / pdf";

    resp.AddHeader("Content-Disposition", "attachment; filename = " + docName);

    x.WriteTo(resp.OutputStream);

    resp.End();

View Complete Thread