开发者

pdf problem Close option c# winform [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I created a PDF file,and sent by mail, now I send one more time I'm getting this error

The process.....because it is beingused by another process

       Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);  

 try 

 {  

     PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("c:\\Test11.pdf",FileMode.Create));  

     doc.Open;  

      Paragraph paragraph = new Paragraph("This is my first line using Paragraph.");  

     Phrase pharse = new Phrase("This is my second line using Pharse.");  

     Chunk chunk = new Chunk(" This is my third line using Chunk.");  
  doc.Add(paragraph);  

     doc.Add(pharse);  
     doc.Add(chunk);  

 }  

catch开发者_Go百科 (DocumentException dex)  

{  

 }  

 finally 

 {  
     doc.Close(); 
 }  


Are you sure the Document class closes the below streams opened in it as well? Looks like it isnt. And to send as an attachment, first finish writing the pdf file to disk. Close it and then use FileMode.Open and FileShare.Read argument to read and send it. That way, multiple files can read it and send it or even in threads its possible.


You can only use the physical PDF file on one application at a time.

Adding it as an attachement and sending it might keep the file open for a while. Copy the file before you do anything with it and simply 'send' or 'show' the copy.

File.Copy the original PDF file and send a copy

File.Copy the original PDF file and show the copy

This should prevent the 'file in use warnings'

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜