C#iText7通过字节数组合并多个pdf页面

时间:2019-12-09 18:36:45

标签: c# pdf itext byte itext7

在itextsharp中使用了此代码,但升级到itext 7后无法使用此代码:

   using (var ms = new MemoryStream()) {
     using (var doc = new Document()) {
        using (var copy = new PdfSmartCopy(doc, ms)) {
            doc.Open();

            //Loop through each byte array
            foreach (var p in pdfByteContent) {

                //Create a PdfReader bound to that byte array
                using (var reader = new PdfReader(p)) {

                    //Add the entire document instead of page-by-page
                    copy.AddDocument(reader);
                }
            }

            doc.Close();
        }
    }

    //Return just before disposing
    return ms.ToArray();

PdfSmartCopy在itext7中不可用,大多数编码器都说pdfwriter的set属性是这样的: pdfwriter.SetSmartMode(true)。 但是我仍然很困惑与此。

0 个答案:

没有答案