invisiblysigndocument.java
来自「Java生成PDF Java生成PDF Java生成PDF」· Java 代码 · 共 66 行
JAVA
66 行
// $Id: InvisiblySignDocument.java,v 1.7 2007/11/16 00:58:51 mike Exp $package org.faceless.pdf2.viewer2.feature;import org.faceless.pdf2.viewer2.*;import org.faceless.pdf2.*;import javax.swing.*;import java.awt.*;import java.util.*;import java.io.*;/** * Creates a new, invisible {@link FormSignature} field and then sign it. * Customising this button can be done the same way you would for * {@link FormBlankSignatureWidgetFactory}, which this class uses to sign. * See that class for more information. * The name of this feature is "InvisiblySignDocument". * <p><i>This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.</i></p> * @since 2.8 */public class InvisiblySignDocument extends ViewerWidget{ private FormBlankSignatureWidgetFactory factory; /** * Create a new InvisiblySignDocument button using the default * {@link FormBlankSignatureWidgetFactory} */ public InvisiblySignDocument() { this(new FormBlankSignatureWidgetFactory()); } /** * Create a new InvisiblySignDocument button using the specified * {@link FormBlankSignatureWidgetFactory} * @param factory the factory */ public InvisiblySignDocument(FormBlankSignatureWidgetFactory factory) { super("InvisiblySignDocument");// setButton("Signatures", "resources/icons/key_add.png", "Invisibly Sign this PDF"); setMenu("Document\tSignAndCertify\tInvisiblySignPDF"); this.factory = factory; } public void action(final ViewerEvent event) { PDF pdf = event.getPDF(); Form form = pdf.getForm(); for (Iterator i = form.getElements().values().iterator();i.hasNext();) { FormElement e = (FormElement)i.next(); if (e instanceof FormSignature && ((FormSignature)e).getState()==FormSignature.STATE_PENDING) { JOptionPane.showMessageDialog(event.getViewer(), SuperJOptionPane.getLocalizedString("PendingSignature"), SuperJOptionPane.getLocalizedString("Alert"), JOptionPane.INFORMATION_MESSAGE); return; } } int num = 1; while (form.getElements().containsKey("Sig"+num)) num++; FormSignature sig = new FormSignature(); try { form.getElements().put("Sig"+num, sig); factory.sign(sig, event.getDocumentPanel()); } catch (Exception e) { SuperJOptionPane.displayThrowable(SuperJOptionPane.getLocalizedString("Error"), e, event.getViewer()); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?