我有一个pdf文件,其中包含索引页,其中包括目标页面的部分。 我能得到的节名(第1.1节,第5.2节),但我不能让目标页码...如何在使用iTextSharp的pdf文件中获取节目标页码?
对于前: http://www.mikesdotnetting.com/Article/84/iTextSharp-Links-and-Bookmarks
这里是我的代码:
string FileName = AppDomain.CurrentDomain.BaseDirectory + "TestPDF.pdf";
PdfReader pdfreader = new PdfReader(FileName);
PdfDictionary PageDictionary = pdfreader.GetPageN(9);
PdfArray Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);
if ((Annots == null) || (Annots.Length == 0))
return;
foreach (PdfObject oAnnot in Annots.ArrayList)
{
PdfDictionary AnnotationDictionary = (PdfDictionary)PdfReader.GetPdfObject(oAnnot);
if (AnnotationDictionary.Keys.Contains(PdfName.A))
{
PdfDictionary oALink = AnnotationDictionary.GetAsDict(PdfName.A);
if (oALink.Get(PdfName.S).Equals(PdfName.GOTO))
{
if (oALink.Keys.Contains(PdfName.D))
{
PdfObject objs = oALink.Get(PdfName.D);
if (objs.IsString())
{
string SectionName = objs.ToString(); // here i could see the section name...
}
}
}
}
}
我如何获得目标页码?
我也不能为某些PDF前访问该科名:http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/adobe_supplement_iso32000.pdf
在这个PDF第九页包含一个部分,我不能让部分。 所以请给我解决方案....
查看我的帖子,http://stackoverflow.com/a/6599734/231316。基本上做一个'oALink.GetAsArray(PdfName.D)',然后在返回的ArrayList的第一项上调用PdfReader.GetPdfObject()。返回的对象应该是对页面的引用。我找不到找到页面“数字”的方法,然后循环遍历每个页面并与我的参考进行比较。 – 2012-04-25 13:00:29
oALink.GetAsArray(PdfName.D)仅返回NULL值。但它与其他pdf一起工作,除了我发布的pdf ... wy? – 2012-04-25 14:09:55