Skip to content

Commit

Permalink
Fix PDF syntax error (cm not allowed after BT) (#1953)
Browse files Browse the repository at this point in the history
Co-authored-by: hvbargen <[email protected]>
  • Loading branch information
hvbtup and hvbargen authored Oct 25, 2024
1 parent a26bf12 commit 5212799
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5212799

Please sign in to comment.