You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unable to add bookmarks at list and list item level.
public class OPBookmarkBuilder extends PdfPageEventHelper {
public void onParagraph(PdfWriter writer, Document document, float position) {
PdfContentByte cb = writer.getDirectContent();
PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
new PdfOutline(cb.getRootOutline(), destination, "Para1-bookmark");
}
}
And the consuming class,
public class PDFGenerator{
public static void main(String[] args) {
Document document = new Document();
final PdfWriter instance = PdfWriter.getInstance(document, new FileOutputStream("testbm.pdf"));
OPBookmarkBuilder bookmarkBuilder = new OPBookmarkBuilder();
instance.setPageEvent(bookmarkBuilder);
instance.setPageEvent(image);
document.open();
instance.setViewerPreferences(PdfWriter.PageModeUseOutlines);
document.add(new Paragraph(....));
List section = new Section();
section.add(new ListItem("test1",...));
section.add(new Table(..));
//Add a dummy empty paragraph so that PDFOutline is added.
document.add(new Paragraph("",...));
section.add(new ListItem("test2",...));
..
..
..
document.add(section);
document.close();
}
}
I am using Lists because chapters and sections are always rendered with numbered bullers. I dont need numbered bullets.
The problem here is that unless I add the list to the document, the position does not move and hence the adding the dummy paragraph is adding outlines at the same destination. In the generated pdf, on clicking the bookmarks it does not navigate to the corresponding the list item.
The text was updated successfully, but these errors were encountered:
Unable to add bookmarks at list and list item level.
And the consuming class,
I am using Lists because chapters and sections are always rendered with numbered bullers. I dont need numbered bullets.
The problem here is that unless I add the list to the document, the position does not move and hence the adding the dummy paragraph is adding outlines at the same destination. In the generated pdf, on clicking the bookmarks it does not navigate to the corresponding the list item.
The text was updated successfully, but these errors were encountered: