Hi,
Could you please help me with creating hyperlinks in pdf document.
I tried with sample document posted, but i am not getting the expected result.
java.io.File file = new java.io.File(“D:/Dharma/Aspose/word-hypderlink-issue/output_Text_Updated.pdf”);
java.io.FileInputStream fis;
try {
fis = new java.io.FileInputStream(file);
Pdf pdf = new Pdf(fis);
Section sec1 = new Section(pdf);
Text text1 = new Text(sec1);
//Add the text paragraph in the paragraphs collection of the section
sec1.getParagraphs().add(text1);
//Add a text segment in the text paragraph
Segment segment1 = text1.getSegments().add(“this is a web link”);
//Set the text in the segment to be underlined
segment1.getTextInfo().isUnderline(true);
//Set the link type of the text segment to Pdf
segment1.getHyperlink().setLinkType(HyperlinkType.Web);
segment1.getHyperlink().setUrl(“http://www.google.com/”);
pdf.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Please help me
Hi Dharmender,
aspose.pdf.Pdf
pdf = new
aspose.pdf.Pdf();<o:p></o:p>
aspose.pdf.Section sec1 = pdf.getSections().add();
aspose.pdf.Text text1 = new aspose.pdf.Text(sec1);
//Add the text paragraph in the paragraphs collection of the section
sec1.getParagraphs().add(text1);
//Add a text segment in the text paragraph
aspose.pdf.Segment segment1 = text1.getSegments().add("this is a web link");
//Set the text in the segment to be underlined
segment1.getTextInfo().isUnderline(true);
//Set the link type of the text segment to Pdf
segment1.getHyperlink().setLinkType(aspose.pdf.HyperlinkType.Web);
segment1.getHyperlink().setUrl("http://www.google.com/");
pdf.save("c:/pdftest/Hyperlinkadded.pdf");
Hi,
Do you have any other class/package in aspose pdf which can be used to create the hyperlinks in existing pdf. or change the text in the existing pdf document as hyerlinks.
Hi Dharmender,