iTextSharp .NET PDF - 无法更改 PDF 生成器

2024-03-04

我正在使用 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();                                                        

                        }

如果您有许可证密钥,则只能更改生产线。需要从以下位置购买许可证密钥iText软件 http://itextpdf.com/contact。有关如何应用许可证密钥的说明与该密钥一起发送。

如果你想免费使用iText,你不能改变生产线。查看 iText 开源版本中每个文件的许可证头:

 * 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 集团已成功起诉一家在未购买许可证的情况下改变生产线的德国公司。您可以在这里找到与此案例相关的一些文档:IANAL:开发者应该了解哪些知识产权和法律知识 http://www.slideshare.net/iTextPDF/ianal-what-developers-should-know-about-ip-and-legal(幻灯片 57-62)

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

总结:如果您没有 iText 的商业许可,则无法合法地更改 iText 中的生产线。如果您有商业许可证,则需要应用许可证密钥。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

iTextSharp .NET PDF - 无法更改 PDF 生成器 的相关文章