MrM*_*MrM 0 c# pdf asp.net asp.net-mvc itextsharp
这似乎是一个微不足道的问题,我想打开现有的pdf模板,编辑并展平文件,然后作为电子邮件附件发送.但是如何设置PdfReader来读取我的Content文件夹中的文件(Content/Documents/PDFFile.pdf).这就是我所提供的错误"(无论我尝试什么路径).pdf都没有找到作为文件或资源".
using (MemoryStream ms = new MemoryStream())
{
//Error is here...
PdfReader reader = new PdfReader("~/Content/Documents/PDFFile.pdf");
PdfStamper formFiller = new PdfStamper(reader, ms);
AcroFields formFields = formFiller.AcroFields;
formFields.SetField("Name", formData.Name);
formFields.SetField("Location", formData.Address);
formFields.SetField("Date", DateTime.Today.ToShortDateString());
formFields.SetField("Email", formData.Email);
formFiller.FormFlattening = true;
formFiller.Close();
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress("to@email.com"));
msg.From = new MailAddress("from@email.com");
msg.Subject = "Application Form";
msg.Body = "TEST";
msg.IsBodyHtml = true;
msg.Attachments.Add(new Attachment(ms, "Application.pdf", "application/x-pdf"));
SmtpClient client = new SmtpClient("10.1.1.15");
client.UseDefaultCredentials = true;
}
Run Code Online (Sandbox Code Playgroud)
有什么建议/想法/建议吗?
| 归档时间: |
|
| 查看次数: |
3327 次 |
| 最近记录: |