Hi,
How to open document in new tab (target=_blank) through builder.InsertHyperlink using Aspose.word and C#?
builder.InsertHyperlink("Test.pdf", $"Test/DisplayPDFFile?documentRelativeUrl={fileName}", false);
Above code snippet is opening in same browser tab.
Please help me on this.
Thanks & Regards,
Souvik
@SouvikMoun You can specify \t
switch. Please see the following link for more information:
https://support.microsoft.com/en-us/office/field-codes-hyperlink-field-864f8577-eb2a-4e55-8c90-40631748ef53
You can use code like this to specify additional hyperlink switches:
FieldHyperlink hyperlink = (FieldHyperlink)builder.InsertHyperlink("test", "https://aspose.com", false);
hyperlink.Target = "_blank";
Hi,
I have tried with above code but still it is opening in same tab.
In Iframe, links are there. Once we are clicked on link, it is opened in same tab.
Can you please help on this.
Thanks & Regards,
Souvik
@SouvikMoun The behavior is not controlled by Aspose.Words. The behavior is handled by the consumer application (MS Word or OpenOffice). FieldHyperlink.Target is the only option available in the hyperlink field that controls this behavior. Aspose.Words properly writes it into the document, but how it is handled by the consumer application is out of Aspose.Words control.
Thanks @alexey.noskov for quick helping and providing the information when required.
1 Like