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

Free Support Forum - aspose.com

Is it possible to add hyper link in Textbox (a button function) in words java?

Hi there,


I am wondering if it is possible to a hyper link in Textbox? In fact, we want to add a button in a docx? We use words.java 13.5.0.

Thanks,
Sheng

Hi Sheng,


Thanks for your inquiry. Sure, you can add a HYPERLINK field inside TextBox Shape by using the following code snippet:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape textBox = new Shape(doc, ShapeType.TEXT_BOX);

textBox.setHeight(50);
textBox.setWidth(200);

textBox.appendChild(new Paragraph(doc));

builder.moveTo(textBox.getFirstParagraph());
builder.insertHyperlink(“display text”,http://www.aspose.com/, false);

doc.getFirstSection().getBody().getFirstParagraph().appendChild(textBox);

doc.save(“C:\Temp\out.doc”);

Sheng:
In fact, we want to add a button in a docx?
Please create your sample Word document using Microsoft Word application and attach it here for our reference. We will provide you code to produce the same document using Aspose.Words.

Best regards,

Thank you so much, Awais!

I want to say: Aspose - excellent product, and excellent support!!

Have a good one!
Sheng

Hi Sheng,


Thanks for your feedback. In case you have further inquires or need any help, please let us know. We’re always glad to help you.

Best regards,