PDFBox : PDPageContentStream's append mode misbehaving

前端 未结 1 1139
礼貌的吻别
礼貌的吻别 2020-11-30 13:27

I am drawing an image on one of the PDF page.. when I use PDPageContentStream stream = new PDPageContentStream(doc, page); to draw image, everything works fine.

相关标签:
1条回答
  • 2020-11-30 13:39

    Use the constructor that has a fifth parameter, so to reset the graphic context.

    public PDPageContentStream(PDDocument document, PDPage sourcePage, boolean appendContent, 
                                boolean compress, boolean resetContext) throws IOException
    

    alternatively, save and restore the graphics state in the first content stream by calling

    saveGraphicsState();
    // ...
    restoreGraphicsState();
    
    0 讨论(0)
提交回复
热议问题