We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert HTML to DOC using Aspose.Words - Problem with centering of the images

Hi,

in aspose-words 20.1 there is still this problem with the centering of images.
We use TinyMCE and a centered image is inserted like

<img style="display: block; margin-left: auto; margin-right: auto;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAlCAIAAAClPtxqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAA2SURBVFhH7c0xDQAgEAAxhPz4/p3hARMXpibde+7sN7KELCFLyBKyhCwhS8gSsoQsIUvIArMPY2Aef7T6lhYAAAAASUVORK5CYII=" alt="red.png">

in IE, FF, Chrom the image is displayed centered. But the pdf output from aspose places the image left aligned.

I know this problem is a really old one but is there a chance that it will be fixed in aspose ?

Here the code:

val tempPdfFile = folder.newFile()
val doc = Document();
val builder = DocumentBuilder(doc);
val htmlWithTinyMceCenteredImg =
    """<img style="display: block; margin-left: auto; margin-right: auto;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAlCAIAAAClPtxqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAA2SURBVFhH7c0xDQAgEAAxhPz4/p3hARMXpibde+7sN7KELCFLyBKyhCwhS8gSsoQsIUvIArMPY2Aef7T6lhYAAAAASUVORK5CYII=" alt="red.png">"""

builder.insertHtml(htmlWithTinyMceCenteredImg)

doc.save(tempPdfFile.path, PdfSaveOptions())

Thank you!

@orgavision

The image is displayed as left aligned in Chrome, Internet Explorer and Firefox. Please make sure that you have shared the correct HTML.

I tried it again and added divs with “test” as text above and below the image to visualize the centering in the browser.

@orgavision

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-20377 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.