开发者

error in generating pdf using iTextSharp means previous pdf file is diplayed

I am working in asp .net mvc3.

I have these statements in controller class:

PdfWriter.GetInstance(doc, new FileStream((Request.PhysicalApplicationPath + "\\Receipt5.pdf"),
FileMode.Create));
doc.Open();
PdfPTable table = new PdfPTable(2);

table.AddCell("tt[0]");
table.AddCell("tt[1]");
doc.close();

All time my values are changing but in pdf sometimes showing old result. please tel开发者_JAVA百科l me what should i do for it that whenever i press done button then new pdf document should generate.

i am using iTextSharp to generate pdf.


It seems that you're not able to replace the old file cause it is locked. Try to delete it and see what happens. Anyway, consider that if more than one user tries to print the same document you can have a concurrency problem. I would suggest you to use a generated file name:

var newFile = System.IO.Path.Combine(Request.PhysicalApplicationPath, Guid.NewGuid().ToString() + ".pdf");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜