List of usage examples for com.lowagie.text.pdf PdfAnnotation HIGHLIGHT_INVERT
PdfName HIGHLIGHT_INVERT
To view the source code for com.lowagie.text.pdf PdfAnnotation HIGHLIGHT_INVERT.
Click Source Link
From source file:com.geek.tutorial.itext.acroform.ListFieldForm.java
License:Open Source License
public ListFieldForm() throws Exception { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ListFieldForm.pdf")); document.open();/* w w w .ja v a 2 s . com*/ // Code 1 String options[] = { "PS3", "XBOX 360", "Wii", "PSP", "NDS", "GBA" }; // Code 2 create drop-down list PdfFormField dropDown = PdfFormField.createCombo(writer, true, options, 0); dropDown.setWidget(new Rectangle(50, 785, 120, 800), PdfAnnotation.HIGHLIGHT_INVERT); dropDown.setFieldName("dropDownList"); dropDown.setValueAsString("PS3"); dropDown.setMKBorderColor(Color.BLACK); writer.addAnnotation(dropDown); // Code 3 create scrollable list TextField scrollableList = new TextField(writer, new Rectangle(150, 740, 250, 800), "scrollableList"); scrollableList.setBackgroundColor(Color.WHITE); scrollableList.setBorderColor(Color.BLUE); scrollableList.setBorderWidth(2); scrollableList.setBorderStyle(PdfBorderDictionary.STYLE_SOLID); scrollableList.setFontSize(10); scrollableList.setChoices(options); scrollableList.setChoiceSelection(0); writer.addAnnotation(scrollableList.getListField()); // Code 4 add function and button for showing state writer.addJavaScript( "function showState(){" + "app.alert('DropDown:'+ this.getField('dropDownList').value +'\\n'+" + "'Scrollable List:'+this.getField('scrollableList').value);" + "}"); PushbuttonField push = new PushbuttonField(writer, new Rectangle(70, 710, 140, 730), "pushAction"); push.setBackgroundColor(Color.LIGHT_GRAY); push.setBorderColor(Color.GRAY); push.setText("Show State"); push.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED); push.setTextColor(Color.BLACK); PdfFormField pushbutton = push.getField(); pushbutton.setAction(PdfAction.javaScript("showState()", writer)); writer.addAnnotation(pushbutton); document.close(); }
From source file:org.xhtmlrenderer.pdf.RadioButtonFormField.java
License:Open Source License
private void createField(RenderingContext c, ITextOutputDevice outputDevice, PdfContentByte cb, PdfWriter writer, PdfFormField group, RadioButtonFormField fieldElem, RadioButtonFormField checked) { Box box = fieldElem.getBox(); Element e = box.getElement(); String onValue = getValue(e); float width = outputDevice.getDeviceLength(fieldElem.getWidth()); float height = outputDevice.getDeviceLength(fieldElem.getHeight()); PdfFormField field = PdfFormField.createEmpty(writer); FSColor color = box.getStyle().getColor(); FSColor darker = box.getEffBackgroundColor(c).darkenColor(); createAppearances(cb, field, onValue, width, height, true, color, darker); createAppearances(cb, field, onValue, width, height, false, color, darker); field.setWidget(outputDevice.createTargetArea(c, box), PdfAnnotation.HIGHLIGHT_INVERT); // XXX createTargetArea already looks up the page, but hopefully a document // won't have enough radio buttons to matter Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = c.getRootLayer().getPage(c, bounds.y); field.setPlaceInPage(page.getPageNo() + 1); field.setBorderStyle(new PdfBorderDictionary(0.0f, 0)); field.setAppearanceState(fieldElem == checked ? onValue : OFF_STATE); if (isReadOnly(e)) { field.setFieldFlags(PdfFormField.FF_READ_ONLY); }//from w w w . j av a2s .co m group.addKid(field); }
From source file:org.xhtmlrenderer.pdf.SelectFormField.java
License:Open Source License
public void paint(RenderingContext c, ITextOutputDevice outputDevice, BlockBox box) { PdfWriter writer = outputDevice.getWriter(); String[][] options = getPDFOptions(); int selectedIndex = getSelectedIndex(); PdfFormField field;/*from w ww . ja v a 2 s. com*/ /* * Comment out for now. We need to draw an appropriate appearance for * this to work correctly. */ /* if (isMultiple(box.getElement())) { field = PdfFormField.createList(writer, options, selectedIndex); } else { field = PdfFormField.createCombo(writer, false, options, selectedIndex); } */ field = PdfFormField.createCombo(writer, false, options, selectedIndex); field.setWidget(outputDevice.createLocalTargetArea(c, box), PdfAnnotation.HIGHLIGHT_INVERT); field.setFieldName(getFieldName(outputDevice, box.getElement())); if (options.length > 0) { field.setValueAsString(options[selectedIndex][0]); } createAppearance(c, outputDevice, box, field); if (isReadOnly(box.getElement())) { field.setFieldFlags(PdfFormField.FF_READ_ONLY); } /* if (isMultiple(box.getElement())) { field.setFieldFlags(PdfFormField.FF_MULTISELECT); } */ writer.addAnnotation(field); }
From source file:questions.forms.FormWithTooltips.java
/** * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, * com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[]) *///from w w w. ja v a 2 s . c o m public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] cb) { kid.setWidget(new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), PdfAnnotation.HIGHLIGHT_INVERT); kid.setUserName(tooltip); try { parent.addKid(kid); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:questions.forms.KidsOnDifferentPages.java
public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] cb) { kid.setWidget(new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), PdfAnnotation.HIGHLIGHT_INVERT); }