I'm using Itextsharp to call a page and then create a pdf from the contents of that page. I want the file to either open in the browser or allow the user to save. The included code creates a file, but gives the following error when trying to open it.
Adobe Reader could not open '' because it is either not a supported file type or because the file has been damaged.
If I use PdfWriter.GetInstance(docu
ment, new FileStream("c:\\Applicatio
n" + bb + ".pdf", FileMode.Create)); the file is created on my file system perfectly, but since the site will sit on a server, I don't want it to work that way. What can I do to fix this?
string bb = Request.QueryString["pid"];
Response.ContentType = "application/pdf";
using (Document document = new Document())
WebClient wc = new WebClient();
string htmlText = wc.DownloadString("http://myserver/GeneratePDF/CreatePDF.aspx?pid=" + bb);
Response.Write(htmlText.Replace("\r", "").Replace("\n", "").Replace(" ", ""));
List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), null);
for (int k = 0; k < htmlarraylist.Count; k++)
catch (Exception ex)