我有一個簡單的PDF檔案,在一個頁面上有鏈接和腳注。當我使用iTextSharp運行注釋檢查時,兩個鏈接都回傳子型別為Link。有什么方法可以分辨這兩個專案的區別嗎?
我確實通過Intellisence檢查了注釋字典的結構,并注意到腳注的注釋物件字典有一個額外的專案,它被命名為 "F",并且該專案有一個值為4。我能否使用 "F "項/引數作為區分鏈接和腳注的方法?
如果有其他問題,請讓我知道
。預先感謝您
。這里是我們的代碼
public string AnyPDFCheckComments(string inFileName, string strUsername, string strFilename)
{
string strCommentType = string.Empty;
string strWidgetFound = string.Empty;
string strPageNumber = string.Empty;
string message = string.Empty。
string strComments = string.Empty。
string strCommentsFound = string.Empty。
int intCommentCount = 0;
PdfReader reader = new PdfReader(inFileName)。
for (int i = 1; i <= readers.NumberOfPages; i)
{
strPageNumber = i.ToString();
PdfDictionary pagedic = reader.GetPageN(i);
PdfArray annotarray = (PdfArray)PdfReader.GetPdfObject(pagedic.Get(PdfName.ANNOTS))。
if (annotarray == null || annotarray.Size == 0)
{
continue;
}
//找出鏈接。
foreach (object annot in annotarray.ArrayList)
{
PdfDictionary annotationDic = null;
if (annot is PdfIndirectReference)
{
annotationDic = (PdfDictionary)PdfReader.GetPdfObject((PdfIndirectReference)annot)。
}
else { annotationDic = (PdfDictionary).
{
annotationDic = (PdfDictionary) annot;
}
PdfName subType = (PdfName)annotationDic.Get(PdfName.SUBTYPE)。
if ((subType.Equals(PdfName.TEXT)) && (strCommentsVariables.IndexOf("text"/span>) != -1)
{
strCommentType = "text";
//break;
}
else if ((subType.Equals(PdfName.LINK)) && (strCommentsVariables.IndexOf("Link") != -1)
{
strCommentType = "Link";
//break;
}
if ((strCommentType != "))
{
strCommentsFound = "是"。
intCommentCount = intCommentCount;
strComments = strComments "<BR>" "一個評論型別為'" "< b>" strCommentType "</b>" "'已被發現在第1頁。" "<b>" strPageNumber "</b>"。
if (intCommentCount == 5)
{
break;
}
else; }
{
strCommentType = string.Empty。
}
}
}
}
return strComments;
}
uj5u.com熱心網友回復:
這段代碼對我們有用
var footnoteIdentifier = annotationDic.Get(PdfName.F) 。
if (footnoteIdentifier != null)
{
繼續。
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/317225.html
標籤:
