Csharp/C#教程:插入文本然后合并pdf分享


插入文本然后合并pdf

我正在使用IText7版本7.0.2.2,我是新手,我正在尝试将几个pdfs同时合并到我首先上传的那个,这工作正常,问题是当我动态尝试在其中一个pdf中插入一些文本然后合并它,我正在使用PdfWriter将一些内容写入pdf然后尝试合并它,但我得到了这个exception: 'Cannot copy indirect object from the document that is being written.

这是我正在使用的一些代码:

 private byte[] MergePdfForms( HttpPostedFileBase firstPdf, List sectionsAndPdf) { var dest = new MemoryStream(); PdfDocument pdf = new PdfDocument(new PdfWriter(dest)); PdfMerger merger = new PdfMerger(pdf); firstSourcePdf = new PdfDocument(new PdfReader(keyValuePair.Value), new PdfWriter(dest)); Document document = new Document(firstSourcePdf); document.Add(new Paragraph(sectionsAndPdf[i].Key).SetBackgroundColor(iText.Kernel.Colors.Color.GRAY)); merger.Merge(firstSourcePdf, 1, subPages); //I'm getting the exception here.. firstSourcePdf.Close(); } 

这是PdfDestination类中的已知错误。 它已修复,并将出现在我们的下一个版本中。 目前您可以使用快照发布,这应该可以解决问题。

上述就是C#学习教程:插入文本然后合并pdf分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1007814.html

(0)
上一篇 2021年12月29日
下一篇 2021年12月29日

精彩推荐