PDFBox的:PDPageContentStream的追加模式行为不端 [英] PDFBox : PDPageContentStream's append mode misbehaving

查看:2553
本文介绍了PDFBox的:PDPageContentStream的追加模式行为不端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的PDF页面的一个绘制图像。当我使用 PDPageContentStream流=新PDPageContentStream(文件,网页); 绘制图像,一切工作正常..见下图。

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.. see below image.

图像

但是当我使用构造 PDPageContentStream(文件,网页,真实,真实); 以创建 PDPageContentStream 和借鉴图像,新增加的图像被上下颠倒..

but when I use constructor PDPageContentStream(doc, page, true, true); to create PDPageContentStream and draw image, the newly added image gets inverted upside down..

图像

没有得到什么错在这里..

not getting what's going wrong here..

PS。我使用的库 PDFBOX-的Andr​​oid

推荐答案

使用具有第五个参数的构造,所以重置图形上下文。

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();

这篇关于PDFBox的:PDPageContentStream的追加模式行为不端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆