I am formatting (or replacing some words in the input with data) input document. And downloading both pdf and word. While creating ,
I am givi1. ng Heading_1 style for table cell items, and adding the setDefaultBookmarksOutlineLevel value 1. But in pdf its not picking the default bookmark.
I am adding listed number for some value in the table. But after the bullet i am getting an extra enter. I try to "write’ for last one, but then last one is not taking as listed.
I am attaching my sample code PdfHeadingBookmark.zip (113.3 KB). Please help me to fix the issue.
Your solution is working fine.
I having another issue regarding space. In my output doc output.zip (15.7 KB) i am adding html in notes and adding special character between this html. You can see in normal view(without showing the hidden words) extra space in the note content. Is there a way i can remove that space ?
Hi,
I tried your solution but it is not giving the expected result. output.zip (15.7 KB) This is the output i got from your solution. Instead of deleting extra space, it deleting hidden word. I only wants to remove the extra space.
The code does not remove the hidden words; instead, it reduces their size to bare minimum and trims extra vertical space by setting paragraph ‘space after’ and ‘space before’ values to 0.
Please ZIP and attach your actual expected DOCX file showing the desired output here for our reference. You can try to create this document manually by using MS Word. Please also list the complete steps that you performed in MS Word to create the expected document on your end. We will then further investigate the scenario and provide you code to achieve the same by using Aspose.Words.
I am attaching my sample code with output, expected output and input document PdfHeadingBookmark (3).zip (143.5 KB)
. I am exporting the generated document. So I want the hidden word in the same paragraph.
Another way is to first check if all characters in last Paragraph of Cell are hidden, then move them to at the end of previous Paragraph and remove the last Paragraph:
Document document = new Document("C:\\Temp\\PdfHeadingBookmark (2)\\output.docx");
ArrayList toBeDeleted = new ArrayList();
for (Paragraph para : (Iterable<Paragraph>) document.getChildNodes(NodeType.PARAGRAPH, true)) {
if (para.isEndOfCell() && areAllRunsHidden(para)) {
if (para.getPreviousSibling() != null &&
para.getPreviousSibling().getNodeType() == NodeType.PARAGRAPH) {
for (Node node : (Iterable<Node>) para.getChildNodes(NodeType.ANY, true))
((Paragraph) para.getPreviousSibling()).appendChild(node);
toBeDeleted.add(para);
}
}
}
for (Paragraph para : (Iterable<Paragraph>) toBeDeleted) {
para.remove();
}
document.save("C:\\Temp\\PdfHeadingBookmark (2)\\awjava-20.8.docx");
public static boolean areAllRunsHidden(Paragraph para) {
boolean flag = true;
for (Run run : (Iterable<Run>) para.getChildNodes(NodeType.RUN, true)) {
if (!run.getFont().getHidden()) {
flag = false;
break;
}
}
return flag;
}