Java words html import wrap text around picture

I have an HTML WYSIWYG edit that allows my users to export this into a word document (using aspose words java). The problem is that the HTML WYSIWYG editor allows the user to wrap text around images and when I export this the image is always placed in the word document as a block. I have attached 2 images “what is exported” shows what the document actually looks like and “what I want” shows the document manually changed to show what I want. Is there any way to get this type of formatting form an HTML import?

Thanks,

Josh

Hi Josh,

Thanks for your inquiry. Could you please attach your input Word document here for testing? I will investigate the issue on my side and provide you more information.

Are you check the HTML output in browser or MS Word? Please share this detail also.

Sorry I think there might be a miss understanding. I am importing HTML and exporting a word document. Does that change what you need?

Hi Josh,

Thanks for sharing this detail. Please note that Aspose.Words mimics the same behaviour as MS Word does. If you load the same html in MS Word and convert it to Doc/Docx file format, you will get the same output.

It would be great if you please share your input html document here for testing. I will investigate the issue and provide you more information.

Hi, here is the HTML I am inserting:

HTML START

<p><img src="http://resumegenius.com/assets/exit_popup/tag.png" alt="" style="font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; font-size: 15px; float: left; margin-right: 10px; margin-bottom: 10px;"></p><p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>

HTML END

The image is on the left and the text wraps close to the image. But when I convert to word it moves the text below the image.

Hi Josh,

Thanks for sharing the detail. Please note that the text wrap issue which you are issue is accutally not an issue. It is expected behaviour. Please increase and decrease the width of document page to check the behaviour of text wrapping. I have attached the output Docx with this post for your kind reference.

Document doc = new Document();
doc.getFirstSection().getPageSetup().setPageWidth(1200);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml("<p><img src=\"http://resumegenius.com/assets/exit_popup/tag.png\" alt=\"\" style=\"font-family: Arial, Helvetica, Verdana, Tahoma, sans-serif; font-size: 15px; float: left; margin-right: 10px; margin-bottom: 10px;\"></p><p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of \"de Finibus Bonorum et Malorum\" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, \"Lorem ipsum dolor sit amet..\", comes from a line in section 1.10.32.</p>");
doc.save(MyDir + "Out.docx");

Thanks, that fixed it up for me

Hi Josh,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.