Kar*_*ran 3 c# asp.net itextsharp
我正在使用iTextSharp产品来更改PDF属性,如下所示.我根本无法更改"PDF Producer"属性.请建议,我哪里出错了.
代码行 信息["Producer"] ="我的制作人";
没有按预期工作.
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();
}
Run Code Online (Sandbox Code Playgroud)
如果您拥有许可证密钥,则只能更改生产者行.需要从iText Software购买许可证密钥.有关如何应用许可证密钥的说明将与该密钥一起发送.
如果您想免费使用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.
Run Code Online (Sandbox Code Playgroud)
您的信息:iText集团已成功起诉一家德国公司,该公司在未购买许可证的情况下更改了生产线.您可以在此处找到与此案例相关的一些文档:IANAL:开发人员应该了解的有关IP和法律的内容(幻灯片57-62)
顺便说一句,我通过这次演讲赢得了JavaOne Rockstar奖:https://twitter.com/itext/status/704278659012681728
总结:如果您没有iText的商业许可,则无法合法更改iText中的生产线.如果您拥有商业许可证,则需要应用许可证密钥.
| 归档时间: |
|
| 查看次数: |
1899 次 |
| 最近记录: |