in my document contains a table and inside table I will have bookmark for a column. And I am taking the bookmark is with row.getRange().getBookmarks(). But for one document, it has bokkmark inside the row but showing row bookmark count as 0. I am attaching the sample document test.docx (41.4 KB)
, can you please help me why I am not getting the row bookmarks.
I am creating word and pdf by altering and uploaded document. In the document I have creating Page with title in Heading_2 style. When I created pdf file with heading as bookmark, heading bookmark is coming but it pointing in a wrong page. Attaching the input filemt_test.docx (12.8 KB) and code
boolean flag = false;
builder.moveToDocumentEnd();
builder.writeln();
for (int i = 0; i < agendaDetail.getAgendaResource().size(); i++)
{
Resource resource = agendaDetail.getAgendaResource().get(i);
//Add the title on new page break as well as bookmark the same
int actualParagraphAlignment = builder.getParagraphFormat().getAlignment();
String attachmentTitle;
attachmentTitle = ATTACHMENT + resource.getName().replaceAll(PDF_EXTENSION, EMPTY_STRING);
//To make the unique bookmark name - have used UUID's random() method because in some cases bookmark name could
//be same (if UUID's random method is not used)
String bookmarkName = resource.getPath() + RUNTIME_BOOKMARKNAME_SEPERATOR + UUID.randomUUID().toString();
builder.insertBreak(BreakType.PAGE_BREAK);
if (flag)
{
flag = false;
builder.startBookmark(emptyItemTitle);
builder.endBookmark(emptyItemTitle);
}
builder.getFont().setName((String)tokenFontMap.get(NAME));
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.getParagraphFormat().getStyle().getFont().setUnderline(Underline.NONE);
builder.getParagraphFormat().setLineSpacing(setCurrentLineSpace((double)(tokenFontMap.get(SIZE)) * 3, builder.getParagraphFormat()));
String sepVariation = true;
builder.getParagraphFormat().getStyle().getFont().setColor((Color)tokenFontMap.get(COLOR));
builder.getFont().setSize(((double)tokenFontMap.get(SIZE)) * 3);
builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
// builder.getPageSetup().setVerticalAlignment(PageVerticalAlignment.CENTER);
builder.writeln(attachmentTitle);
// builder.writeln(" ");
builder.startBookmark(bookmarkName);
builder.endBookmark(bookmarkName);
logger.error("Font size inside prototype build up :" + builder.getFont().getSize());
// clear the formatting info
// builder.getParagraphFormat().clearFormatting();
// Get the file's page count from agenda Resource
for (int pgCount = 0; pgCount < resource.getFilePageCount(); pgCount++)
{
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.NORMAL);
// removing blank page fo r skip empty case
if (variationMap.containsKey(SEPARATOR_KEY) || (!isSkipEmpty || pgCount > 0))
{
builder.insertBreak(BreakType.PAGE_BREAK);
}
builder.write(" ");
if (true && false && i == agendaDetail.getAgendaResource().size() - 1 && pgCount == resource.getFilePageCount() - 1)
{
builder.getParagraphFormat().setAlignment(ParagraphAlignment.JUSTIFY);
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
Section currentSection = builder.getCurrentSection();
PageSetup pageSetup = currentSection.getPageSetup();
pageSetup.setVerticalAlignment(pageVerticalAlignment);
// Disable inheriting the first page header/footer from previous section.
pageSetup.setDifferentFirstPageHeaderFooter(false);
// Reset page borders.
if (pageSetup.getBorderAppliesTo() == PageBorderAppliesTo.FIRST_PAGE)
pageSetup.getBorders().clearFormatting();
if (pageSetup.getBorderAppliesTo() == PageBorderAppliesTo.OTHER_PAGES)
pageSetup.setBorderAppliesTo(PageBorderAppliesTo.ALL_PAGES);
}
if (flag && false)
{
flag = false;
builder.startBookmark(emptyItemTitle);
builder.endBookmark(emptyItemTitle);
}
}