1

I can convert html files to pdfs with iTextSharp using code from Kyle in ITextSharp HTML to PDF? The files save correctly and I can open them from Windows Explorer without a problem.

But when I then try to download one of the new pdfs with a very basic

Response.AppendHeader("content-disposition", "attachment; filename=" + fname);
Response.ContentType = type;
Response.WriteFile(fname);
Response.End();

the downloaded file won't open in Adobe. I opened it in a text editor and saw that what had actually come over was the full html code + the pdf code.

Why is the html inside the file (and only the downloaded version!) and how do I get rid of it?

Community
  • 1
  • 1
thchaver
  • 331
  • 5
  • 14

1 Answers1

1

I'm guessing you just need to do a Response.Clear() first to get rid of the rest of the page that is coming down the pipe.

Tim
  • 14,999
  • 1
  • 45
  • 68