c# - iTextSharp .NET PDF - 无法更改 PDF Producer

标签 c# asp.net itext

我正在使用 iTextSharp 产品来更改 PDF 属性,如下所示。 我根本无法更改“PDF Producer”属性。请建议,我哪里错了。

代码行 info["制作人"] = "我的制作人";

没有正常工作。

      string sourcePath = tbPath.Text;
                IList<string> dirs = null;
                string pdfName = string.Empty;
                string OutputPath = string.Empty;

                DirectoryInfo di = new DirectoryInfo(sourcePath);
                DirectoryInfo dInfo = Directory.CreateDirectory(sourcePath + "\\" + "TempDir");

                OutputPath = Path.Combine(sourcePath,"TempDir");          

                dirs = Directory.GetFiles(di.FullName, "*.pdf").ToList();

                for (int i = 0; i <= dirs.Count - 1; i++)
                {
                    try
                    {
                        PdfReader pdfReader = new PdfReader(dirs[i]);
                        using (FileStream fileStream = new FileStream(Path.Combine(OutputPath, Path.GetFileName(dirs[i])),
                                                          FileMode.Create,
                                                          FileAccess.Write))
                        {                                         

                           PdfStamper pdfStamper = new PdfStamper(pdfReader, fileStream);

                            Dictionary<string, string> info = pdfReader.Info;
                            info["Title"] = "";
                            info["Author"] = "";
                            info["Producer"] = "My producer";   ////THIS IS NOT WORKING..                                                                

                            pdfStamper.MoreInfo = info;    
                            pdfStamper.Close();         
pdfReader.Close();                                                        

                        }

最佳答案

如果您有许可证 key ,您只能更改生产商行。需要从 iText Software 购买许可证 key .有关如何应用许可证 key 的说明随该 key 一起发送。

如果你想免费使用iText,你不能改变生产者的路线。查看开源版iText中每个文件的license header:

 * In accordance with Section 7(b) of the GNU Affero General Public License,
 * a covered work must retain the producer line in every PDF that is created
 * or manipulated using iText.

供您引用:iText Group 已成功起诉一家德国公司,该公司在未购买许可证的情况下更改生产线。您可以在此处找到与此案例相关的一些文档:IANAL: What developers should know about IP and Legal (幻灯片 57-62)

顺便说一句,我通过这次演讲获得了 JavaOne Rockstar 奖:https://twitter.com/itext/status/704278659012681728

enter image description here

总结:如果您没有 iText 的商业许可,您就不能合法地更改 iText 中的生产者行。如果您有商业许可证,则需要应用许可证 key 。

关于c# - iTextSharp .NET PDF - 无法更改 PDF Producer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36351302/

相关文章:

java - 如何在内存中创建日历图像以添加到 PDF?

c# - 为什么我不能在 IOrderedQueryable 上调用 Skip?

c# - C# 6 结构中的无参数构造函数

C# 为什么 127 = 这个位串?

asp.net - 使用 ASP.NET 开发服务器测试多个域

c# - 处理多项操作的最佳方式是什么?

c# - 如何从客户端脚本访问参数

java - 使用 iText pdfHTML 的 PDF 页面大小和格式

java - 使用抽象方法设计通用API,但在传递给匿名类时必须使用final 变量。有更好的方法来实现这一点吗?

c# - 对于从星期一开始的 DayOfWeek 枚举的每个循环?