Dear support,
we encountered a problem with the text alignment of SVG images.
Maybe it is related to SVG rendering issue text-anchor="middle" but the workaround there seems not to work for us.
private void test() throws Exception {
// Arrange
File targetPdfFile = new File(tmpFolder.getAbsolutePath());
String targetPdfFilePath = targetPdfFile + "/" + UUID.randomUUID() + ".pdf";
FileOutputStream fileOutputStream = new FileOutputStream(targetPdfFilePath);
Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);
InputStream svgFile = classLoader.getResourceAsStream("test aspose alignment.svg");
// Act
docBuilder.insertImage(svgFile);
doc.save(fileOutputStream, new PdfSaveOptions());
// Assert
System.out.println("Saved pdf here: " + targetPdfFilePath);
// ...
}
test aspose alignment.zip (32.6 KB)
In the PDF you can see that the vertical, middle-aligned text “test1” is aligned on the left border.
And the middle-aligned text “hallo Rolle hehe” is also aligned wrong and overlays a icon.
Thank you for your help !