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

Free Support Forum - aspose.com

Text Alignment of Inserted SVG is Incorrect in output DOCX using Java

We are considering updating from Aspose.Words 20.6 to 21.7 and are trying to find out what differences there are. We noticed that there’s an SVG text bug in 21.7 that wasn’t there in 20.6. See output_21.7.docx in the attached files.zip. Example code:

final Document doc = new Document();
final DocumentBuilder builder = new DocumentBuilder(doc);

files.zip (30.9 KB)


We have tested the scenario and 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-22498. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


Please use CompatibilityOptions.OptimizeFor method as shown below to get the desired output.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertImage(MyDir + @"input.svg");
doc.save(MyDir + "output.docx");

Could you give us an update on this issue please?

You’ve suggested using the optimizeFor-Method. I couldn’t find out from the documentation what ramifications this might have. Does this restrict the output to a certain type of features or change the behavior of anything else? We’re asking because we don’t anything else to break because of this.


Currently, there is no update available on this issue. We will inform you once there is any news available on it.

When you are using a version of MS Word that is newer than the version used to create your document, you typically see Compatibility Mode in the title bar. The CompatibilityOptions.OptimizeFor method allows to optimize the document contents as well as default Aspose.Words behavior to a particular versions of MS Word.

When a document is opened in compatibility mode, the layout of document may disturb. You can use this method to prevent MS Word from displaying “Compatibility mode” ribbon upon document loading.

@bmpi We have completed analyzing WORDSNET-22498 and decided not to make any fixes for this issue for now, because the bug is located not in Aspose.Words’ code but rather in MS Word’s SVG renderer.

The recommended workaround for this issue is to switch the document to an older version before inserting SVG images. This will force Aspose.Words to convert inserted SVG to the EMF format.

DocumentBuilder builder = new DocumentBuilder();

// Lower the document version in order to force Aspose.Words to convert SVG to EMF.
// Word 2007 is the highest version that doesn't support SVG.

// Insert SVG.

// Restore the document version. This step is optional.

We are going to close the issue with the “Not a Bug” resolution.