Hello!
I have another issue (adding to HTML with checkbox to PDF), when I convert HTML with checkboxes to PDF. In this case the the checkbox is overlayed by the text.
I also converted the HTML with MS Word 2016 to PDF, which produces a better looking pdf: htmlWithCheckboxes.zip (184.7 KB)
Is there a way to get a similar looking result using Aspose.Words?
Kind regards
@dvtdaten Could you please attach your source HTML document. I have checked with your original HTML from other thread and see cell width where checkbox is inserted is less then required. Please try suing the following code to fix this:
Document doc = new Document("C:\\Temp\\in.html");
// Replace form field with the corresponding Wingdings characters.
for (Field f : doc.getRange().getFields())
{
if (f.getType() == FieldType.FIELD_FORM_CHECK_BOX)
{
FormField ff = (FormField)f.getEnd().getPreviousSibling();
Run checkBox = new Run(doc, ff.getChecked() ? "\u00FE" : "\u00A8");
checkBox.getFont().setName("Wingdings");
f.getEnd().getParentNode().insertAfter(checkBox, f.getEnd());
f.remove();
}
}
// Fix table width issues.
for (Table t : doc.getFirstSection().getBody().getTables())
{
t.setAllowAutoFit(true);
t.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);
}
doc.save("C:\\Temp\\out.pdf");
Alternatively, specify cell width explicitly in your HTML. out.pdf (41.1 KB)
Ah yes, the HTML document from the other thread has similar problems.
Thank you, @alexey.noskov, the problem is solved with your hints.
Kind regards
1 Like