Last post Nov 11, 2009 06:21 PM by soulfly1973
Mar 29, 2007 11:24 PM|artmasa|LINK
Can somebody help me with this.
Ive been trying to do something and no success. It seems like the stream is not well formed and I receive an error in adobe reader that says the file is corrupted.
Here is my code:
string formFile = this.Server.MapPath(@"\library\doctemp\") + "cmoinmail.pdf";
PdfReader reader = new PdfReader(formFile);
MemoryStream ms = new MemoryStream();
PdfStamper stamper = new PdfStamper(reader, fs);
AcroFields fields = stamper.AcroFields;
stamper.Writer.CloseStream = false;
stamper.FormFlattening = true;
MailAddress maFrom = new MailAddress("email@example.com")
MailAddress maTo = new MailAddress(firstname.lastname@example.org);
MailMessage email = new MailMessage(maFrom, maTo);
email.Subject = "Your new order at EvanTell";
Attachment attch = new Attachment(ms, new System.Net.Mime.ContentType("application/pdf"));
SmtpClient mailSender = new SmtpClient("server");
Apr 03, 2007 08:20 AM|mcools|LINK
I was struggling with this exact problem, and ultimately I found a solution. The position of the memory stream needs to be reset before the attachment is made, so you need to insert
ms.Position = 0
(sorry, don't know the C# equivalent... Probably ms.position(0) or something) between lines 22 and 23 in your source code, and possibly flush the stream.
Hope this helps!
May 15, 2007 04:23 PM|artmasa|LINK
Thanks for your reply
This is a great solution
Nov 11, 2009 06:21 PM|Soulfly1973|LINK
does anyone no the equalivent of writer.CloseStream for the pdfwriter in vb.net?