在 iText 中使用 PdfContentByte 解决此问题。当我尝试创建新页面时,我使用以下代码-
canvas = writer.getDirectContent();
canvas.saveState();
canvas.stroke();
canvas.restoreState();
...
canvas.endText();
itextDocument.newPage();
setUpperFontAndSize(canvas);
canvas.beginText();
该问题发生在调用 endText() 时。有什么办法解决吗?
最佳答案
OP 说
The issue is occurring at the time of calling endText()
根据该方法的源代码,该异常表明没有匹配的 beginText()
之前打电话。
block 引用>A text object begins with the BT operator and ends with the ET operator, as shown in the Example, and described in Table 107.
EXAMPLE
BT …Zero or more text operators or other allowed operators… ET
... text objects cannot be statically nested ...
关于java - com.itextpdf.text.exceptions.IllegalPdfSyntaxException : Unbalanced begin/end text operators,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27835553/