From 521279949be5d66e182f0cf0cf4c1893a74acb3d Mon Sep 17 00:00:00 2001 From: Henning von Bargen Date: Fri, 25 Oct 2024 11:16:55 +0200 Subject: [PATCH] Fix PDF syntax error (cm not allowed after BT) (#1953) Co-authored-by: hvbargen <37015738+hvbargen@users.noreply.github.com> --- .../eclipse/birt/report/engine/emitter/pdf/PDFPage.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java index c3f260753eb..45469cc45a7 100644 --- a/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java +++ b/engine/org.eclipse.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java @@ -456,12 +456,17 @@ private void drawRawLine(float startX, float startY, float endX, float endY, flo private void drawText(String text, float textX, float textY, FontInfo fontInfo, float characterSpacing, float wordSpacing, Color color, CSSValue align) { contentByte.saveState(); + + // This is not allowed inbetween beginText/endText, thus it must come first. + contentByte.concatCTM(1, 0, 0, 1, textX, transformY(textY, 0, containerHeight)); + // start drawing the text content contentByte.beginText(); if (null != color && !Color.BLACK.equals(color)) { contentByte.setColorFill(color); contentByte.setColorStroke(color); } + BaseFont font = getBaseFont(fontInfo); font.setIncludeCidSet(this.pageDevice.isIncludeCidSet()); @@ -562,7 +567,7 @@ private PdfAction createPdfAction(String hyperlink, String bookmark, String targ } private void setTextMatrix(PdfContentByte cb, FontInfo fi, float x, float y) { - cb.concatCTM(1, 0, 0, 1, x, y); + if (!fi.getSimulation()) { cb.setTextMatrix(0, 0); return;