Identify the anchor tag in a word document using aspose.words in java


#1

Hi Team,

My requirement is to Analyse the document identify the anchor tag.If the anchor tag is present then print the statement as"anchor is present" .

please kindly help me to solve the same.

Input file es-alfouneh-tong-figs-R2.zip (2.9 MB)
Thanks & regards,
priyanga G


#2

@priyanga,

Thanks for your inquiry. As per my understanding, you want to know either hyperlink fields are present in the document or not. If this is the case, please use following code example. Hope this helps you.

Document doc = new Document(MyDir + "es-alfouneh-tong-figs-R2.docx");
foreach (Field field in doc.Range.Fields)
{
    if (field.Type == FieldType.FieldHyperlink)
    {
        Console.WriteLine("Hyperlink field is present in the document");
    }
}

#3

Hi @tahir.manzoor,

Thank you for your reply.

could you please provide the code example in java

Thanks & Regards,
Priyanga G


#4

@priyanga,

Thanks for your inquiry. Please check the following Java code example.

Document doc = new Document(MyDir + "es-alfouneh-tong-figs-R2.docx");
for (Field field : doc.getRange().getFields())
{
    if (field.getType() == FieldType.FIELD_HYPERLINK)
    {
        System.out.println("Hyperlink field is present in the document");
    }
}