Hi,
I need to provide the user with the ability to print a webform.
To do this, I can convert the webform to the html and then to a word doc, which the user can print.
Can anyone provide some links to sample code to be able to do this?
Also, the user can attach a word/xsl (doc,docx,xsl,xslx) file to the webform, and I would like the content of this file to be included in the word file created from the webform. What is the best way to do this, again, any links to sample code would be appreciated,
thanks,
Brian
Hi
Thanks for your request. You can use the following simple code to convert HTML to Word:
Document doc = new Document("in.html");
doc.save("out.doc");
But it is not quite clear for me how word/xsl (doc,docx,xsl,xslx) files can be attached to web form. Could you please clarify how these files are represented in your HTML and how you would like to insert them into the final Word document?
Best regards,
Hi,
thanks for your reply.
The attached documents will have previously been uploaded to the server, and so can be accessed by the client code of aspose, or aspose directly,
thanks,
Brian
Hi Brian,
Thank you for additional information. In this case, you can just open these documents using Aspose.Words and insert them into the main document if it is necessary. Please see the following link for more information:
https://docs.aspose.com/words/java/insert-and-append-documents/
https://docs.aspose.com/words/java/insert-and-append-documents/
Please let me know if you need more information, I will be glad to help you.
Best regards.
Hi,
thanks for you reply, I will look into those links.
I am trying to create a word doc from an in-memory html string, what is best way to do this.
Document takes input stream or file as constructor args, I have tried to create input stream from string, but am getting a ‘java.nio.charset.UnsupportedCharsetException: UTF-7’ exception,
thanks,
Brian
Hi Brian,
Could you please try using the code below when loading your HTML string into a new document object and see if the exception still occurs.
InputStream is = new ByteArrayInputStream(html.getBytes());
Document doc = new Document(is, "", LoadFormat.HTML, "");
where html is the string containing the HTML code.
You can also create a document from HTML by inserting the code using document builder into a blank document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml(html);
Please see the documentation regarding inserting elements into the document using the DocumentBuilder here.
Thanks,
Hi,
thanks for prompt reply.
That is working, but one one issue.
The formatting of the text in the word doc does not match the html. For example, the borders on some tables are missing, text is bolder. Below is some sample html. Note the below html converts perfectly to pdf using asponse .net pdf.
thanks,
Brian
<table width="100%">
<tr>
<td align="left" style="FONT-FAMILY:arial;FONT-SIZE:9pt;FONT-WEIGHT:bolder;text-decoration:underline; ">Commercial L/C's:</td>
</tr>
</table>
<table width="100%" style="border:1px solid black;FONT-FAMILY:arial;FONT-SIZE:9pt;" cellpadding="3" cellspacing="0">
<tr>
<td align="left" style="border-bottom:1px solid black;FONT-WEIGHT:bolder;">Standard/Other:</td>
<td colspan="5" align="left" style="border-bottom:1px solid black;"> </td>
</tr>
<tr>
<td align="left" style="border-bottom:1px solid black;border-right:1px solid black;FONT-WEIGHT:bolder;">Type:</td>
<td align="left" style="border-bottom:1px solid black;border-right:1px solid black;FONT-WEIGHT:bolder;">Rate:</td>
<td colspan="4" align="left" style="border-bottom:1px solid black;FONT-WEIGHT:bolder;">Min./Flat</td>
</tr>
Hi
Thank you for additional information. The problem with your table occurs, because Aspose.Words does not fully support table styles upon HTML import. Your request has been linked to the appropriate issue. You will be notified as soon as it is supported.
Best regards,
Hi,
Do you have a list of what is and what is not supported by aspose words regarding html import.
It does not have to be complete, I just want a feel for what is in or out.
Also are there any timelines for when this issues will be fixed,
thanks,
Brian
Hi Brian,
Thanks for your request. Currently, we have a list of supported features upon exporting to HTML. You can find it here:
https://docs.aspose.com/words/java/convert-a-document-to-html-mhtml-or-epub/
But, unfortunately, there is no such list for HTML import.
Regarding estimates, it is difficult to provide you any reliable estimate. We plan complete reengineering of HTML import/export in order to better support it. But, I cannot promise you any timeframe.
Best regards,
The issues you have found earlier (filed as WORDSNET-3163) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(12)