Hi,
I am outputing a table in aspose.words which i want to populate with some html text and (not plain text) so that the cell appears as an Rich text.
for example:
Cell w_cell = m_bldr.insertCell();
m_bldr.write(a_cellValue);
this prints but it has the HTML tags all around.
I want it properly formatted as per the HTML tags.
The HTML contains only formatted text and no images/tables etc.
For example:
it gives me this output in the table cell:
hhhh
gggg
whereas what i want is:
hhhh
gggg
Please help me with this info as i am sure i am missing something special that needs to be done for this.
found the solution. use m_bldr.insertHTML(string)
Hi Aslam,
Thanks for your query. It is nice to hear from you that you have found the solution. Please let us know if you have any more queries.
For painting the table I have Used InsertHTML API of DocumentBuilder but, this also changes the font style of document.
Is there any way so that my documents Font style remains same.
Hi Aslam,
Thanks for your query. It would be great if you please share HTML used in InsertHTML method for investigation purposes. Are you using font styles in CSS?
Thanks for replying...
My html used is as follows
Resources are available in the organization that can be invited into the project:
Resource</strong> |
Project</strong> |
Allocation Start Date |
Allocation End Date |
Ramesh K |
Project A |
01-Feb-11 |
28-Feb-11 |
Manish P |
Project B |
03-Jan-11 |
07-Jan-11 |
|
Project C |
10-Jan-11 |
14-Jan-11 |
In the above case
This gives the output as
Resources are available in the organization that can be invited into the project:
Resource |
Project |
Allocation Start Date |
Allocation End Date |
Ramesh K |
Project A |
01-Feb-11 |
28-Feb-11 |
Manish P |
Project B |
03-Jan-11 |
07-Jan-11 |
|
Project C |
10-Jan-11 |
14-Jan-11 |
In the above case
Here font style remains same as we have set for the content printed above table.
Font style get changed for all the contet after table is inserted.
I have set the style of the document using DocumentConfigParser.setStyle()
Hi Aslam,
Thanks for sharing the details. I have tested the scenario with following code snippet and have not found any issue with font styles while using latest version of Aspose.Words for Java. Please us the latest version of Aspose.Words for Java. Please find the output Docx file in attachment. If you still face problem, please share your code along with documents for investigation purposes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
String str = "shared html contnets....";
builder.insertHtml(str);
doc.save(MYDir + "AsposeOut-Java.docx");
I have used
DocumentBuilder.getParagraphFormat().setStyle(“Some Custom Style”));.
and then insertHTML.
when i use this kind of code,
The data in HTML above table does not change, but after table the data gets changed.
Please find my outpt doc.
In this doc you find that
First line is having proper style (our custom style which we set.- Field Value)
but when insertHTMl inserts a table style gets changed to (Normal + Ariel)
as it changed in my doc. For table and line document style is changed
Hi Aslam,
Thanks for sharing the details. DocumentBuilder.InsertHtml method uses the fonts specified in HTML. If you want to apply “Some Custom Style” on your html, you need to specify this custom style in your html as shown below.
<span style=“Some Custom Style”>Resource</strong>
Please let us know if you have any more queries.