button - itext PushbuttonField 行为

标签 button itext behavior

我正在使用 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/

相关文章:

xcode - 如何使 scrollView 自动滚动?

java - iText:带有 PdfpTable 的 Pdf 专色

java - PDF 文本 | ClassCastException - com.lowagie.text.Paragraph 无法转换为 com.lowagie.text.Table

android - iText 尝试创建 PDF 文件时出现问题

iphone - HTML5 iPhone preventDefault() 不会从 "copy"停止以在触摸时出现

python - Python 元类的 __new__ 方法中的奇怪行为

jquery - 需要制作一个在大多数浏览器中工作的 jQuery 脚本(跨浏览器)

JavaFx - 将两个 'setOnAction' 设置为同一个按钮

java - 将按钮添加到集合 SWT 中

html - anchor 标签的随机行为