Need assistance in population of content from word document using dotx template

Hi,
I have converted the html content to word document(.doc) using aspose. But now when I download the word document i should use the dotx template and populate the content of the word document and present to the browser a docx file. Can any one help me in this.
Thanks
Krishnakanth

Hi,
I have converted the html content to word document(.doc) using aspose. But now when I download the word document i should use the dotx template and populate the content of the word document and present to the browser a docx file. Can any one help me in this.
Krishnakanth

Hi
Thank you for your interest in Aspose.Words. I think, the best way to fill the template document with data is using Mail Merge feature. Please follow this link to learn more:
https://docs.aspose.com/words/java/mail-merge-and-reporting/
Data for MailMerge can come from a source in a variety of formats supported by Java. It can be ResultSet, an array of values or from any custom data source.
Hope this helps.
Best regards,

Hi,
Thanks for quick response. Data for Mail Merge can be populated from data source. If I have content in the word document and the content should use the template format when I save it in docx.Can the aspose accepts the .dotx format. If so can you please specify any example that the word document content populated by using the template(Formats and styles of the template).
Thanks,
Krishnakanth

Hi
Thanks for your request. Sure, you can use DOTX as a template for your documents. Just use your DOTX document as an input document:

Document doc = new Document(@"in.dotx");

Best regards,

Hi,

Thanks for your quick response. I am using the following aspose\ code so that it will be clear what I need exactly.

Document doc = new Document("in.html", LoadFormat.HTML);
doc.save(out.doc, SaveFormat.doc);

By this I am able to convert the HTML to Word Document and I have set in the response object to open it in the browser.

Now whenever I downloaded the word document, the content should be populated using dotx template and save it in docx.This thing I am not sure how to do with aspose.Could you please give any idea or an example

Regards,
Krishnakanth

Hello
Thanks for your request. Unfortunately, it is not quite clear for me what you would like to achieve. Could you please attach you input and expected output documents here for testing? I will check them and provide you more information.
Best regards,

Hi,
Thanks for your response. I have attached the sample code. By this, I can convert the HTML file to the word document and can download the document. I need a help for the below request.
For the Word download function. When I download the Word doc I should use the dotx template and populate with the content of the document and present to the browser a docx file.
Kindly suggest me in the above request.
Thanks,
Krishnakanth

Hi
Thank you for additional information. But unfortunately, it is still not quite clear where you stuck.
Do you need to insert your HTML into a DOTX template? If so, you can easily achieve this using DocumentBuilder.insertHtml method. Please follow the link for more information:
https://reference.aspose.com/words/java/com.aspose.words/documentbuilder/#insertHtml-java.lang.String
So, you can open your DOTX template insert HTML and save the output document as DOCX.
Best regards,

Hi,
Thanks for your response. I am getting the alert when I open the word document. Could you please suggest me.
The below is the code :

String html="<p>This is the test paragraph";
html="<html>"+html+"</html>"; 
String templatePath="@/template.dotx";
InputStream inputStream = new FileInputStream(new File(templatePath));
Document doc = new Document(inputStream);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml(html);
doc.save(outstream, SaveFormat.DOCX);

When I open the word document I am getting the alert as “Word Cannot start the converter mswrd632.wpc”.
JSP code is:

java.io.OutputStream outstream = response.getOutputStream();
response.setContentType("application/msword");
HTMLToWordConversion(outstream);

Kindly suggest me.
Thanks,
Krishnakanth

Hi,
When I save it in .doc format I am not getting any alerts when I open the word document. But I need to save it in docx.
Any suggestions…
Thanks,
Krishnakanth

Hello
Thanks for your request. Could you please attach your “template.dotx” document here for testing? I will check the problem on my side and provide you more information.
Best regards,

Hi,
template.dotx have been attached.
Thanks,
Krishnakanth

Hello
Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words for Java 10.1.0. Please try using the latest version of Aspose.Words for Java. You can download this version from here:
https://releases.aspose.com/words/java
Also I think this problem is not related to Aspose.Words. You can try to find the answer in Google (Word Cannot start the converter mswrd632.wpc).
https://support.microsoft.com/en-us/topic/ms09-073-description-of-the-security-update-for-windows-xp-windows-2000-and-windows-server-2003-december-8-2009-7f94e304-9466-086b-6eff-4abb589f8431
Best regards,

Hi,
Thanks for your information.
Regards,
Krishnakanth

Hi,
By the way how we know the Aspose.Words version for Java. It silly question from my side but to make sure the version I am using.
Regards,
Krishnakanth

Hi
Thanks for your request. To check version of Aspose.Words for java, unzip Aspose.Words.jar, open META-INF\ MANIFEST.MF file in notepad, you will see the following:

Manifest-Version: 1.0
Specification - Title: Aspose.Words for Java
Specification-Version: 10.1.0.0
Specification-Vendor: Aspose Pty Ltd
Implementation-Title: Aspose.Words for Java
Implementation-Version: 10.1.0.0
Implementation-Vendor: Aspose Pty Ltd
Release-Date: 2011.05.30

Best regards,