Create Word file using Json/HTML text

Hi,

I am new to Aspose.Word. Can you proved me help in creating a .doc or .docx file using Json resultor HTML file content.

Below is my Json data

[{"ProductId":1,"ProductName":"ABC, totalt, m2.","Year":2010,"Number":17476,"Pct":-10,"UnitId":3,
"Unit":"meter","UnitShort":"m2","County_AppId":2,"County_Description":"desc",
"Country_Appid":1,"Country_Description":"ind","SegmentId":2,
"Segment":"segemfnf","BuildingClassId":8,"BuildingClass":"PQR"}]

HTML file will have all columns that are there in Json object.

Looking forward for help.

Thanks.

Trevor

Hi Trevor,

Thanks for your inquiry. It seems that you are using Aspose.Words for Cloud. Could you please share your input Html document along with expected output document? Please also share some detail of your use case. We will then provide you more information about your query.

Hi,

Below is the HTML code that i want to convert to PDF using Aspose. Word API

table, th, td {border: 1px solid black; border-collapse: collapse;}

ProductId ProductName Year Number Pct
1 ABC 2016 123456 dd12
2 PQR 2016 554 ddty12

It contains data in table format.

Looking forward for you help.

Thanks.

Trevor

Hi Trevor,
Thanks for sharing the detail. You can use DocumentBuilder.InsertHtml to insert an HTML fragment or whole HTML document into the document.
You may also load the whole HTML document into Aspose.Words DOM and export it to Pdf. Please check following code examples for your kind reference. Hope this helps you.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertHtml(
    "<P align='right'>Paragraph right</P>" + "<P align='left'><b>Implicit paragraph left</b></P>" +
    "<div align='center'>Div center</div>" + "<h1 align='left'>Heading 1 left.</h1>");

doc.Save(MyDir + "Out.pdf", SaveFormat.Pdf);

Document doc = new Document(MyDir + "in.html");
doc.Save(MyDir + "Out.pdf", SaveFormat.Pdf);