相关疑难解决方法(0)

如何将生成的pdf文件作为附件发送到C#的电子邮件中?

我有生成pdf文件的代码,我想将其作为电子邮件的附件发送.

我有这个代码:

        FileContentResult fileContentResult = File(fileName, "application/pdf", "file.pdf");
Run Code Online (Sandbox Code Playgroud)

我有这个代码通过电子邮件发送附件

        Attachment a = new Attachment();
        sender.SendMail("a@a.com", "a@a.com", "subject", "Body", a);
Run Code Online (Sandbox Code Playgroud)

如何将FileContentResult转换为Attachment对象?

c# email

6
推荐指数
1
解决办法
1万
查看次数

iText7在内存而不是物理文件中创建PDF

如何使用itext7在内存流中创建PDF,而不是物理文件?我不知道如何在最新版本中进行操作,有帮助吗?

我尝试了以下代码,但pdfSM未正确填充:

string filePath = "./abc.pdf";

MemoryStream pdfSM = new ByteArrayOutputStream();

PdfDocument doc = new PdfDocument(new PdfReader(filePath), new PdfWriter(pdfSM));
.......

doc.close();
Run Code Online (Sandbox Code Playgroud)

完整的测试代码如下,供您参考,它在filePath进入PdfWriter时有效,但不适用于内存流:

    public static readonly String sourceFolder = "../../FormTest/";

    public static readonly String destinationFolder = "../../Output/";

    static void Main(string[] args)
    {

        String srcFilePattern = "I-983";
        String destPattern = "I-129_2014_";

        String src = sourceFolder + srcFilePattern + ".pdf";
        String dest = destinationFolder + destPattern + "_flattened.pdf";
        MemoryStream returnSM = new MemoryStream();

        PdfDocument doc = new PdfDocument(new PdfReader(src), new PdfWriter(returnSM));

        PdfAcroForm form …
Run Code Online (Sandbox Code Playgroud)

c# memory pdf itext

2
推荐指数
1
解决办法
3377
查看次数

标签 统计

c# ×2

email ×1

itext ×1

memory ×1

pdf ×1