Hi Team,
could you please help us with an issue we encountered when trying to use to-do list like checkboxes. I attached a simple console application to reproduce the issue. We have an html which we insert into a word template document. The HTML looks fine before the insertion to the word document. I attached a ShouldLookLikeThis.png image (in the zip) to demonstrate the expected behaviour.
However the generated docx, pdf, and image files look completely different, ignoring any kind of style defaulting to the very basic checkbox style in word.
Thank you for time and effort on this. Any help is greatly appreciated.
It seems you are experiencing issues with the rendering of a to-do list with checkboxes in a Word document generated from HTML. The discrepancies in appearance between the original HTML and the generated formats (DOCX, PDF, and image) can often arise from how different formats handle styles and elements.
To address this, you might want to consider using structured document tags (SDTs) for checkboxes in your Word document. This approach allows for better control over the appearance and behavior of checkboxes. Here’s a simple example of how to create a checkbox using Aspose.Words in Java:
import com.aspose.words.*;
public class CheckboxExample {
public static void main(String[] args) throws Exception {
// Create a new document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a checkbox structured document tag
StructuredDocumentTag checkbox = new StructuredDocumentTag(doc, SdtType.CHECKBOX, MarkupLevel.INLINE);
builder.insertNode(checkbox);
// Save the document
doc.save("CheckboxExample.docx");
}
}
In this example, a checkbox is created and inserted into the document. You can customize the appearance of the checkbox by modifying its properties or applying styles.
If you continue to face issues with the rendering of your to-do list, I recommend checking the styles applied to your HTML and ensuring they are compatible with Word’s rendering engine. Additionally, you may want to explore the possibility of using custom styles in your Word document to achieve the desired look.
If you need further assistance, please feel free to share more details about your HTML structure or any specific styles you are using.
@ottap You should note, that Aspose.Words is designed to work with MS Word documents. HTML documents and MS Word documents object models are quite different and it is not always possible to provide 100% fidelity after conversion one model to another. In most cases Aspose.Words mimics MS Word behavior when work with HTML. If you convert your HTML to DOCX or PDF using MS Word the result is even worse then using Aspose.Words:
MS Word: ms.docx (14.9 KB)
Aspose.Words: out.docx (7.9 KB)
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.
Enables storage, such as cookies, related to analytics.
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.