Not able to getting box as it is there in the html format

 <p><strong>I, XYZ Employee:</strong></p>
    <label for="usualAddress">Usual address of employee*</label>
    <p><input type="text" name="Address" id="usualAddress" value="ABC, XYZ"></p>
    <label for="suburb">Suburb/town*</label>
    <p><input type="text" name="Suburb" id="suburb" value="DEF"></p>
    <label for="state">State/territory*</label>
    <p><input type="text" name="State" id="state" value="GHI"></p>
    <label for="postcode">Postcode*</label>
    <p><input type="text" name="PostCode" id="postcode" value="111111"></p>

When i convert it to document i am not getting boxes boxes are getting removed automatically

Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
builder.InsertHtml(contentInHtml, HtmlInsertOptions.UseBuilderFormatting);
MemoryStream pdfStream = new MemoryStream();
document.Save(pdfStream, SaveFormat.Docx);

@Amrinder_Singh Input textbox controls are convert to text input form fields in MS Word documents:
out.docx (7.9 KB)

This is an expected behavior. Could you please provide what output you would like to get after converting the provided HTML to MS Word document?

I want to download my html content in pdf, what i am doing i am putting the content in word (docx).
and then converting it into pdf.

My final output i want if text box inside box in pdf

@Amrinder_Singh I am afraid it is impossible to preserve original HTML document layout as it look in the browser after converting it to MS Word document. Please note, 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 format to another. In most cases Aspose.Words mimics MS Word behavior when work with HTML documents.

In your case you can consider enabling PdfSaveOptions.PreserveFormFields in this case textbox input controls will be converted to PDF as PDF form fields:

Document doc = new Document(@"C:\Temp\in.html");
PdfSaveOptions opt = new PdfSaveOptions();
opt.PreserveFormFields = true;
doc.Save(@"C:\Temp\out.pdf", opt);

out.pdf (56.4 KB)

okok, got it, i will try this, Thank you so much for the Quick response

1 Like