我正在其中一个 PDF 页面上绘制图像。当我使用 PDPageContentStream stream = new PDPageContentStream(doc, page);
绘制图像时,一切正常。请参见下图。
但是当我使用构造函数 PDPageContentStream(doc, page, true, true);
创建 PDPageContentStream
并绘制图像时,新添加的图像倒置了。
没有明白这里出了什么问题..
附言。我正在使用图书馆 PdfBox-Android
最佳答案
使用具有第五个参数的构造函数来重置图形上下文。
public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent,
boolean compress, boolean resetContext) throws IOException
或者,通过调用保存和恢复第一个内容流中的图形状态
saveGraphicsState();
// ...
restoreGraphicsState();
关于java - PDFBox : PDPageContentStream's append mode misbehaving,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27919436/