本文整理汇总了Java中com.lowagie.text.pdf.PdfFormField.createPushButton方法的典型用法代码示例。如果您正苦于以下问题:Java PdfFormField.createPushButton方法的具体用法?Java PdfFormField.createPushButton怎么用?Java PdfFormField.createPushButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfFormField
的用法示例。
在下文中一共展示了PdfFormField.createPushButton方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.lowagie.text.pdf.PdfFormField; //导入方法依赖的package包/类
/**
* Generates an Acroform with a PushButton
*/
@Test
public void main() throws Exception {
Document.compress = false;
// step 1: creation of a document-object
Document document = new Document(PageSize.A4);
// step 2:
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("pushbutton.pdf"));
// step 3: we open the document
document.open();
// step 4:
PdfFormField pushbutton = PdfFormField.createPushButton(writer);
PdfContentByte cb = writer.getDirectContent();
cb.moveTo(0, 0);
PdfAppearance normal = cb.createAppearance(100, 50);
normal.setColorFill(Color.GRAY);
normal.rectangle(5, 5, 90, 40);
normal.fill();
PdfAppearance rollover = cb.createAppearance(100, 50);
rollover.setColorFill(Color.RED);
rollover.rectangle(5, 5, 90, 40);
rollover.fill();
PdfAppearance down = cb.createAppearance(100, 50);
down.setColorFill(Color.BLUE);
down.rectangle(5, 5, 90, 40);
down.fill();
pushbutton.setFieldName("PushMe");
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, normal);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_ROLLOVER, rollover);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_DOWN, down);
pushbutton.setWidget(new Rectangle(100, 700, 200, 750), PdfAnnotation.HIGHLIGHT_PUSH);
writer.addAnnotation(pushbutton);
// step 5: we close the document
document.close();
}
示例2: main
import com.lowagie.text.pdf.PdfFormField; //导入方法依赖的package包/类
/**
* Generates an Acroform with a PushButton
*
* @param args
* no arguments needed here
*/
public static void main(String[] args) {
System.out.println("PushButton");
Document.compress = false;
// step 1: creation of a document-object
Document document = new Document(PageSize.A4);
try {
// step 2:
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "pushbutton.pdf"));
// step 3: we open the document
document.open();
// step 4:
PdfFormField pushbutton = PdfFormField.createPushButton(writer);
PdfContentByte cb = writer.getDirectContent();
cb.moveTo(0, 0);
PdfAppearance normal = cb.createAppearance(100, 50);
normal.setColorFill(Color.GRAY);
normal.rectangle(5, 5, 90, 40);
normal.fill();
PdfAppearance rollover = cb.createAppearance(100, 50);
rollover.setColorFill(Color.RED);
rollover.rectangle(5, 5, 90, 40);
rollover.fill();
PdfAppearance down = cb.createAppearance(100, 50);
down.setColorFill(Color.BLUE);
down.rectangle(5, 5, 90, 40);
down.fill();
pushbutton.setFieldName("PushMe");
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, normal);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_ROLLOVER, rollover);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_DOWN, down);
pushbutton.setWidget(new Rectangle(100, 700, 200, 750), PdfAnnotation.HIGHLIGHT_PUSH);
writer.addAnnotation(pushbutton);
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}