英文:
How to change redact color
问题
我正在使用 itext 7.1.8
版本,我需要修改隐私保护颜色,但是当我尝试这样做时,颜色没有改变。
我的代码如下:
PdfReader reader = new PdfReader(new FileInputStream(pdfDoc));
PdfWriter writer = new PdfWriter(new FileOutputStream("ResultFile.pdf"));
PdfDocument doc = new PdfDocument(reader, writer);
final PdfPage page = doc.getFirstPage();
final float[] borderColorBlack = { 0, 0, 0 };
PdfAnnotation redact = new PdfRedactAnnotation(new Rectangle(1, 1, 37, 20))
.setTitle(new PdfString(""))
.setColor(new float[] {0, 0, 0})
.setFlag(PdfAnnotation.TOGGLE_NO_VIEW)
.put(PdfName.Subj, PdfName.Redact)
.put(PdfName.OC, new PdfArray(borderColorBlack));
page.addAnnotation(redact);
PdfCleanUpTool cleaner = new PdfCleanUpTool(doc, true);
cleaner.cleanUp();
doc.close();
我如何修改隐私保护颜色区域?
英文:
I'm using itext 7.1.8
and I need to change the redact color but when I'm trying to do it the color doesn't change.
My code looks like the following:
PdfReader reader = new PdfReader(new FileInputStream(pdfDoc));
PdfWriter writer = new PdfWriter(new FileOutputStream("ResultFile.pdf"));
PdfDocument doc = new PdfDocument(reader, writer);
final PdfPage page = doc.getFirstPage();
final float[] borderColorBlack = { 0, 0, 0 };
PdfAnnotation redact = new PdfRedactAnnotation(new Rectangle(1, 1, 37, 20))
.setTitle(new PdfString(""))
.setColor(new float[] {0, 0, 0})
.setFlag(PdfAnnotation.TOGGLE_NO_VIEW)
.put(PdfName.Subj, PdfName.Redact)
.put(PdfName.OC, new PdfArray(borderColorBlack));
page.addAnnotation(redact);
PdfCleanUpTool cleaner = new PdfCleanUpTool(doc, true);
cleaner.cleanUp();
doc.close();
How can I change the redact color area?
答案1
得分: 1
我在这里找到了解决此问题的方法。我只是添加了一个标志:
PdfAnnotation redact = new PdfRedactAnnotation(new Rectangle(1, 1, 37, 20))
.setTitle(new PdfString(""))
.setColor(new float[] {0, 0, 0})
.setFlag(PdfAnnotation.TOGGLE_NO_VIEW)
.put(PdfName.Subj, PdfName.Redact)
.put(PdfName.IC, new PdfArray(borderColorBlack)) // 在这里添加了代码
.put(PdfName.OC, new PdfArray(borderColorBlack));
英文:
I found a solution to this issue here. I just have added flag:
PdfAnnotation redact = new PdfRedactAnnotation(new Rectangle(1, 1, 37, 20))
.setTitle(new PdfString(""))
.setColor(new float[] {0, 0, 0})
.setFlag(PdfAnnotation.TOGGLE_NO_VIEW)
.put(PdfName.Subj, PdfName.Redact)
.put(PdfName.IC, new PdfArray(borderColorBlack)) // Added code here
.put(PdfName.OC, new PdfArray(borderColorBlack));
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论