I am using the below code to resize the text box around the sentences and paragraphs after changing the font style or size but I find sometimes it doesn’t execute well giving shape variable a null, Is there a more precise workaround for this issue.
@Duminda The whole document is built with floating objects, such document are very hard to edit in MS Word or programmatically due to the flow nature of MS Word documents. Changing shapes properties might lead to the document content reflowing, that might have unexpected results with document build with floating object, like yours.
@Duminda I am afraid there is no solution. It is not normally recommended to use absolutely positioned content to build MS Word documents if it is supposed to edit them.
Is there a method to open a html file using aspose word so that content will be absolutely positioned, or any properties tha needs to be added to html file
@Duminda No, Unfortunately, there is no option to import HTML content as absolutely positioned.
Please note, Aspose.Words is designed to work with MS Word documents. HTML documents and MS Word documents object models are quite different and it is not always possible to provide 100% fidelity after conversion one format to another. In most cases Aspose.Words mimics MS Word behavior when importing HTML documents.
So after changing the font due to difference in font metrics text becomes narrower And since each line is a separate paragraph in a shape the text is not reflowed.
How was the original document generated? It looks like it is a result of conversion of Fixed Page document (like PDF or XPS) to Word. Or the result of image to text conversion.
@Duminda Have you tried using Aspose.Words to convert HTML to DOCX? Aspose.Words in most cases behaves the same way as MS Word does when deal with HTML documents.
We initially planned on using aspose.cloud html API to convert html to docx but is there a aspose.cloud word API to convert html to docx and get a better result. or to get a better document after changing fonts of an converted document.
var wordsApi = new WordsApi(config);
using var requestDocument = File.OpenRead(htmlFilePath);
var convertRequest = new ConvertDocumentRequest(requestDocument, "docx", @"C:\home\site\wwwroot\", "testFile");
var conversion = await wordsApi.ConvertDocument(convertRequest);
The file fails to convert from html to docx, Am i missing something ?
@Duminda Since you have encountered problems with using Aspose.Words Cloud API, it would be better to ask in the dedicated support forum: https://forum.aspose.cloud/c/words/17
My colleagues from Cloud team will help you shortly.
But anyways it would be better to attach your input HTML document for testing, so we could reproduce the problem on our side.
@Duminda Unfortunately, it is not quite clear what space between pages you are talking about. If possible could you please provide the expected output in MS Word document form.
You should note, that actually there is no “page” concept in MS Word documents, since they have flow nature, the same as HTML. The consumer applications like MS Word or Open Office layout the document into pages on the fly. So when you change font of the document, it is reflowed accordingly.