我正在使用 iText 创建 pdf,并在 pdf 的左侧和右侧创建了“不可见”(即无颜色、无图标)按钮 (PushbuttonField)。单击时,文档将前进到下一页或上一页。
按钮的默认行为(至少在 Acrobat 中)是单击时颜色反转。我想关闭这个反馈。
Acrobat 对于默认为“反转”的按钮有一个“行为”属性(除了可在 iText 中访问的布局之外)。我希望将行为设置为“无”,但无法弄清楚如何在 iText 中定义按钮。
这是我正在使用的(功能 - 保存不需要的视觉反馈)代码:
PushbuttonField prevButton = new PushbuttonField(writer, new Rectangle(0, 0, 72, pageHeight), "Prev Page" + buttonNo++);
field = prevButton.getField();
field.setAction(new PdfAction(PdfAction.PREVPAGE));
writer.addAnnotation(field);
最佳答案
如果没有测试,我会说你需要:
field.setHighlighting(PdfFormField.HIGHLIGHT_NONE);
你能测试一下并确认我是否正确吗?
作为替代方案,您可以使用:
field.setWidget(new Rectangle(0, 0, 72, pageHeight), PdfAnnotation.HIGHLIGHT_NONE);
关于button - itext PushbuttonField 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20834697/