如何使用C#在Pdf文件中查找所有内部链接,我的代码用于外部链接,如下所述。 [英] How Can I Find All Internal Links In Pdf File Using C# , My code For External Links Mentioned below.
本文介绍了如何使用C#在Pdf文件中查找所有内部链接,我的代码用于外部链接,如下所述。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮助
我如何处理pdf项目我想找到pdf文件中的所有内部链接我找到所有外部链接但我不能查找内部链接。
外部链接代码。我正在使用ItextSharp dll。
PdfArray Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);
foreach (PdfObject A in Annots.ArrayList)
{
// 将特定于itext的对象转换为通用PDF对象
PdfDictionary AnnotationDictionary =(PdfDictionary )PdfReader.GetPdfObject(A);
// 确保此注释有链接
if (!AnnotationDictionary.Get(PdfName.SUBTYPE).Equals(PdfName.LINK))
继续;
// 确保此注释具有操作
< span class =code-keyword> if (AnnotationDictionary.Get(PdfName.A)== null )
继续跨度>;
// 获取当前注释的ACTION
PdfDictionary AnnotationAction = AnnotationDictionary.GetAsDict(PdfName.A);
// PdfDictionary AnnotationAction =(PdfDictionary)AnnotationDictionary.Get(PdfName.A);
if (AnnotationAction.Get(PdfName.S).Equals(PdfName.URI))
{
解决方案
尝试查看此网站用C#(100%.NET)中的PDF提取文本[ ^ ]或者您也可以查看将PDF转换为C#中的文本 [ ^ 一>
pls help
How can I am working on a pdf project i want to find all internal links in pdf file i finding all external links but i am not able to find internal links.
code for external links. I am using ItextSharp dll.
PdfArray Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);
foreach (PdfObject A in Annots.ArrayList)
{
//Convert the itext-specific object as a generic PDF object
PdfDictionary AnnotationDictionary = (PdfDictionary)PdfReader.GetPdfObject(A);
//Make sure this annotation has a link
if (!AnnotationDictionary.Get(PdfName.SUBTYPE).Equals(PdfName.LINK))
continue;
//Make sure this annotation has an ACTION
if (AnnotationDictionary.Get(PdfName.A) == null)
continue;
//Get the ACTION for the current annotation
PdfDictionary AnnotationAction = AnnotationDictionary.GetAsDict(PdfName.A);
// PdfDictionary AnnotationAction = (PdfDictionary)AnnotationDictionary.Get(PdfName.A);
if (AnnotationAction.Get(PdfName.S).Equals(PdfName.URI))
{
解决方案
try checking out this site Extract Text from PDF in C# (100% .NET)[^] or you could also check out Converting PDF to Text in C#[^]
这篇关于如何使用C#在Pdf文件中查找所有内部链接,我的代码用于外部链接,如下所述。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文