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?
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.
精彩评论