We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Using hyperlinks within LINQ

Hello,


Could you please let me know if there is any way to include hyperlinks in reports generated using linq.

I am using Aspose Word Java 15.8.0.

Hi Puneet,


Thanks for your inquiry. I think, after building report, you can move cursor to the desired places and insert hyperlinks in document:

http://www.aspose.com/docs/display/wordsjava/Moving+the+Cursor
http://www.aspose.com/docs/display/wordsjava/com.aspose.words.DocumentBuilder.insertHyperlink+method

Best regards,

Hi Awais Hafeez,


Thanks for your response, tip is helpful.

But I am generating report using LINQ , so I would prefer to use LINQ for the same.

Like there is tag for image :<<image [getImageByteArray()]>> and switch for HTML <<[getHTMLText()] -html>>, is there any similar solution(tag or switch) for hyperlinks in LINQ?

Regards
Puneet

Hi Puneet,


Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi Awais,


Any update on this?

Hi Puneet,


Thanks for your inquiry. Hyperlinks can be achieved, but it is a bit tricky. Consider the following class:
public static class LinkInfo
{
public String Alias;
public String Link;
}
  1. In the MS Word editor, add text "<<[Alias]>>"
  2. Select the text and make it a hyperlink using some dummy url like "abc"
  3. Select the hyperlink and press Shift+F9
  4. Replace “abc” with "<<[Link]>>"
  5. Select the hyperlink and press Shift+F9

Document doc = new Document(getMyDir() + “input.docx”);

LinkInfo lnk = new LinkInfo();
lnk.Alias = “Aspose”;
lnk.Link = “http://www.aspose.com;

ReportingEngine engine = new ReportingEngine();
engine.buildReport(doc, lnk);

doc.save(getMyDir() + “awjava.docx”);

Alternatively, a HTML block can be used as follows:

<<["" + Alias + “”] -html>>


Both templates are specified in attached input.docx. I hope, this helps.

Best regards,