Are OpenOffice hidden sections
supported in Aspose Words?
We have OpenOffice .odt documents that contain sections that are shown or hidden based on the value of a user field, IsEmail.
This is used to render different content when a document is emailed or printed.
This works using when OpenOffice to generate the content, but not when using Aspose Words for Java 22.7.
The code below simulates printing by setting IsEmail to false, and emailing by setting IsEmail to true, generating a PDF for each. In both cases, the flag is being ignored; both sections are rendered.
Document document = new Document("Conditional Section.odt");
VariableCollection variables = document.getVariables();
for (Map.Entry<String, String> variable: variables) {
System.out.println(variable.getKey() + "=" + variable.getValue());
}
document.getVariables().add("IsEmail", "false");
document.updateFields();
document.save("Conditional Section - IsEmail-false-actual.pdf");
document.getVariables().add("IsEmail", "true");
document.updateFields();
document.save("Conditional Section - IsEmail-true-actual.pdf");
See the zip for the expected and actual results obtained:
- Conditional Section.odt - the source .odt that is being merged
- screenshot.png - screenshot of the .odt in OpenOffice, showing how the section ‘Print Letterhead’ is hidden when IsEmail == true
- Conditional Section - IsEmail-false-expected.pdf - the expected result when setting IsEmail to false, generated using OpenOffice
- Conditional Section - IsEmail-false-actual.pdf - the actual result when setting IsEmail to false, generated using Aspose Words
- Conditional Section - IsEmail-true-expected.pdf - the expected result when setting IsEmail to true, generated using OpenOffice
- Conditional Section - IsEmail-true-actual.pdf - the actual result when setting IsEmail to true, generated using Aspose Words
Conditional Section.zip (740.5 KB)