读取pdf的ITextSharp异常:重建失败:字典键“"不是名字 [英] ITextSharp exception to read pdf: Rebuild failed: Dictionary key "" is not a name

查看:398
本文介绍了读取pdf的ITextSharp异常:重建失败:字典键“"不是名字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.net(c#)项目中使用iTextSharp库收到特定pdf文件的未处理异常。我无法理解我想上传的pdf的具体内容,虽然我可以看到基本的pdf我从互联网功能下载工作。
以下代码部分:

I receive unhandled exception for specific pdf files using iTextSharp libraries in .net (c#) project. I cannot understand what is specific with pdf I want to upload, though I can see that with basic pdf I download from internet functionality works. The following part of code:

string pdfTemplate =url to specific pdf;
var pdfReader = new PdfReader(pdfTemplate);

string pdfTemplate ="url to specific pdf"; var pdfReader = new PdfReader(pdfTemplate);

抛出异常:
重建失败:字典键Z不是名称。在文件指针224;原始消息:字典键Z不是名称。在文件指针224

throw exception: Rebuild failed: Dictionary key Z is not a name. at file pointer 224; Original message: Dictionary key Z is not a name. at file pointer 224

请提出任何建议?我没有想法...

Please, any suggestions? I'm out of ideas...

推荐答案

文档信息词典中有错误:

There is an error in the document info dictionary:

%PDF-1.4
1 0 obj
<<
/Title (þÿ)
/Creator (þÿ)
/Producer (þÿ Q t   4 . 8 . 2   \( C \)   2 0 1 1   N o k i a   C o r p o r a t i o n   a n d / o r   i t s   s u b s i d i a r y \( - i e s \))
/CreationDate (D:20131111142910)Z)
>>
endobj 

CreationDate 值有两个右括号。 iText正确地假定第一个是正确的,即完成值,因此,将 Z 视为下一个条目的关键。

There are two closing brackets for the CreationDate value. iText correctly assumes the first one to be correct, i.e. finishing the value, and, therefore, considers the Z to be the key of the next entry.

但是一个键必须是一个名字,一个名字以斜杠开头,但是这个名字没有斜线。的句法的错误 !!因此:

But a key has to be a name, and a name starts with a slash, but this name-to-be has no slash. Syntax-Error!! Thus:


字典键Z不是名称。在文件指针224

Dictionary key Z is not a name. at file pointer 224

PdfReader 作为失败尝试后的最后手段再次阅读PDF,这次首先尝试重建交叉引用。由于问题与交叉引用无关,这显然会再次失败。因此:

The PdfReader as a last resort after a failure tries to read the PDF again, this time first trying to reconstruct the cross references. As the Problem is not related to the cross references at all, this obviously fails again. Thus:


重建失败:字典键Z不是名称。在文件指针224;原始消息:字典键Z不是名称。在文件指针224

Rebuild failed: Dictionary key Z is not a name. at file pointer 224; Original message: Dictionary key Z is not a name. at file pointer 224

此语法错误的创建可能是Qt错误(Qt 4.8.2在此处被命名为创建者) 。

The creation of this syntax error might be a Qt bug (Qt 4.8.2 being named as the creator here).

PS:您是否尝试在Adobe Reader中打开此文件的文档属性?这里没有任何东西出现,这肯定是由于这个问题。

PS: Have you tried opening the document properties of this file in Adobe Reader? Nothing pops up here which surely is due to that issue.

这篇关于读取pdf的ITextSharp异常:重建失败:字典键“&quot;不是名字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆