Hi Team,
We have upgraded Aspose.words.dll from version 11.8 to 23.1.
The alignment(align = “justify”), font size , font text etc. are not working after the dll upgrade.
Attaching the sample html which is dynamically getting generated from our Database. We use the method builder.InsertHtml(); to render the html.
SampleHtml.zip (2.6 KB)
Could you please check the attached html file and let me know how to fix this issue.
@Febinbabu As I can see font size and font family is properly preserve by Aspose.Words. Here is code I have used for testing:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(File.ReadAllText(@"C:\Temp\in.html"));
doc.Save(@"C:\Temp\out_inserthtml.docx");
out_inserthtml.docx (10.5 KB)
Regarding paragraph justification, in this case Aspose.Words mimics MS Word behavior. In MS Word justification is specified on the paragraph level. In your HTML is is specified on table cell level:
<td align="justify">
Hi Alexy,
Thanks for the clarification.
We are having 2k plus documents. The html contents are getting generated dynamically from the stored procedures in most of the cases. As per your previous response, I assume that we need to make the styling changes in each of the document accordingly. Do we have any generic solution which can be applied in the code level, rather than making the change in each document level?
Also, Can you please share me a html document where all these styles are provided explicitly according to the Aspose standards. So that we can do the changes in our templates accordingly.
@Febinbabu The only possible solution on code level can be preprocessing of your HTML documents before passing them to Aspose.Words. For example you can consider using Aspose.HTML to manipulate HTML documents.
Aspose.Words is designed to work with MS Word documents at first. And most features supported upon conversion document from Word to HTML is also supported on HTML document import by Aspose.Words. So you can implement what is required in MS Word, Save the document to HTML using Aspose.Words and check how styles are applied in the output HTML file.
Hi Alexy,
I tried to convert one word file to html.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(File.ReadAllText(@"C:\Users\Desktop\DocGen\DocgenCC\Testing\Input\out_inserthtml fromAspose.docx"));
doc.Save(@"C:\Users\Desktop\DocGen\DocgenCC\Testing\output\out_inserthtml fromAspose.html", SaveFormat.Html);
But the html file did’t get generated properly . Attaching the Genetated html file here.
Please do let me know if any changes are required in the code.OutputHtml.zip (9.1 KB)
InputWordDoc.zip (13.3 KB)
@Febinbabu DOCX file is not HTML, you should use the following code to convert DOCX to HTML:
Document doc = new Document(@"C:\Temp\in.docx");
doc.Save(@"C:\Temp\out.html");
Hi Alexy,
if we modify all of our Stored procedures which return html contents according to the current aspose standard, it would works fine with the current version. However, is there a possibility that html standards may change in a future version of aspose? If that happens, will we need to rework the changes we’re making now?
@Febinbabu, could you please clarify what HTML standards do you mean?
Hi Denis,
We were using Aspose.words.dll version 11.8 in our applications. Recently we upgraded it to version 23.1. Getting too many cosmetic issues in the documents after upgradation.
Giving one of the examples below.
The given html template was working fine with Aspose 11.8 version.
Working Html with AsposeWords11.8.zip (353 Bytes)
But the same html template does not work fine with Aspose 23.1. Space between the paragraphs is getting removed.
image.png (16.4 KB)
As Aspose team suggested, I have created a word document with the proper formatting and converted it into html using aspose.words.This generated html used with a merge filed in our actual template and it works fine. The generated html also given below.
Working Html with AsposeWords23.1.zip (462 Bytes)
Both of the Html I have provided here generates the same output in browser but different in the document according to the apsose.words version. The syntax is also different in the new html generated with Aspose.Words.23.1. This I mean by current HTML standard.
We currently have more than 2000 documnets in our application. We’re currently upgrading to Aspose.Words version 23.1 and modifying the html to match how it’s generated by the same version.However , if we upgrade to a newer version in future, will we need to modify the html to align with that new version again.?
Also, we would like to know what’s the best practice Aspose team suggest in this kind of scenarios?
@Febinbabu, regarding your prevous question, yes, behavior and output documents produced by Aspose.Words can change in newer versions because Aspose.Words is constantly being developed. Aspose.Words uses Microsoft Word’s behavior as a standard, and since Microsoft Word behavior changes with updates, Aspose.Words also updates own behavior. Different versions of Microsoft Word can show the same document differently, and Aspose.Words tries to eventually have the same behavior as the latest version of Microsoft Word.