When running UpdateFields() on a document, I noticed the field text in the footer was refreshed in bold even if the field was not in bold and the field style is set to be preserved.
Code:
var document = new Document(“test.docx”);
document.UpdateFields();
document.Save(“testout.docx”);
I’ve attached the test and output file for your reference. You can see the field in the footer of original document is not in bold but in the output document it is bold.
Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15857. You will be notified via this forum thread once this issue is resolved.
@kiran5388 Unfortunately, the issue is not resolved yet. Could you please attach your input, output document and code that will allow us to reproduce the problem? We will check whether you have encountered the same problem.
@Crane The issue reported in this thread is not resolved yet. It has been postponed and is not yet scheduled for development. Please accept our apologies for your inconvenience.
@Crane Could you please attach your input, output document and code that will allow us to reproduce the problem? We will check whether you have encountered the same problem.
@Crane Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side. I have changed text and style names to English (default) for testing:
Document document = new Document();
com.aspose.words.List list = document.getLists().add(ListTemplate.NUMBER_DEFAULT);
DocumentBuilder documentBuilder = new DocumentBuilder(document);
documentBuilder.write("This is some text");
documentBuilder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
documentBuilder.getCurrentParagraph().getListFormat().setList(list);
documentBuilder.getCurrentParagraph().getListFormat().setListLevelNumber(0);
documentBuilder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
documentBuilder.write("Another text");
documentBuilder.getCurrentParagraph().getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
documentBuilder.getCurrentParagraph().getListFormat().setList(list);
documentBuilder.getCurrentParagraph().getListFormat().setListLevelNumber(0);
documentBuilder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
for (Section section : document.getSections()) {
HeaderFooter headerFooter = new HeaderFooter(document, HeaderFooterType.HEADER_FIRST);
section.getHeadersFooters().add(headerFooter);
Paragraph paragraph = new Paragraph(document);
paragraph.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
paragraph.appendField("STYLEREF \"Heading 1\" \\n");
paragraph.appendField("STYLEREF \"Heading 1\" \\* MERGEFORMAT");
for (Object childNode : paragraph.getChildNodes(NodeType.RUN, true)) {
if (childNode instanceof Run) {
Run run = (Run)childNode;
run.getFont().setBold(false);
run.getFont().setColor(Color.RED);
}
}
headerFooter.getParagraphs().add(paragraph);
PageSetup pageSetup = section.getPageSetup();
pageSetup.setDifferentFirstPageHeaderFooter(true);
pageSetup.setBorderSurroundsHeader(true);
pageSetup.setOddAndEvenPagesHeaderFooter(true);
}
document.updateFields();
document.save("C:\\Temp\\out.docx");
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.