Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JODF
>
Tutorial
> Add bookmark
The following example shows you how to add a bookmark.
import com.independentsoft.office.odf.BookmarkEnd; import com.independentsoft.office.odf.BookmarkStart; import com.independentsoft.office.odf.Paragraph; import com.independentsoft.office.odf.Text; import com.independentsoft.office.odf.TextDocument; public class Example { public static void main(String[] args) { try { TextDocument doc = new TextDocument(); Paragraph p1 = new Paragraph(); p1.add("Hello World"); doc.getBody().add(p1); Text bookmarkText = new Text("Some text here"); BookmarkStart bookmarkStart = new BookmarkStart(); bookmarkStart.setName("BookmarkName"); bookmarkStart.add(bookmarkText); BookmarkEnd bookmarkEnd = new BookmarkEnd(); bookmarkEnd.setName("BookmarkName"); p1.add(bookmarkStart); p1.add(bookmarkEnd); doc.save("c:\\test\\output.odt", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*