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:
1 string formFile = this.Server.MapPath(@"\library\doctemp\") + "cmoinmail.pdf";
2 PdfReader reader = new PdfReader(formFile);
3 MemoryStream ms = new MemoryStream();
4 PdfStamper stamper = new PdfStamper(reader, fs);
5 AcroFields fields = stamper.AcroFields;
6
7
8 fields.SetField("subtotal", this.Order.SubTotal.ToString());
9 fields.SetField("discount", this.Order.Discount.ToString());
10 fields.SetField("tax", this.Order.Tax.ToString());
11 fields.SetField("shipping", this.Order.Shipping.ToString());
12 fields.SetField("total", this.Order.Total.ToString());
13
14 stamper.Writer.CloseStream = false;
15
16 stamper.FormFlattening = true;
17 stamper.Close();
18
19 MailAddress maFrom = new MailAddress("some@domain.com")
20 MailAddress maTo = new MailAddress(another@domain.com);
21 MailMessage email = new MailMessage(maFrom, maTo);
22 email.Subject = "Your new order at EvanTell";
23 Attachment attch = new Attachment(ms, new System.Net.Mime.ContentType("application/pdf"));
24 email.Attachments.Add(attch);
25
26 SmtpClient mailSender = new SmtpClient("server");
27 mailSender.Send(email);
Thanks for your help in advance