/** * Returns the appearance characteristics dictionary. * * @return the appearance characteristics dictionary */ public PDAppearanceCharacteristicsDictionary getAppearanceCharacteristics() { COSBase mk = this.getCOSObject().getDictionaryObject(COSName.MK); if (mk instanceof COSDictionary) { return new PDAppearanceCharacteristicsDictionary((COSDictionary) mk); } return null; }
public static void main(String[] args) throws IOException { // Load the PDF document created by SimpleForm.java try (PDDocument document = PDDocument.load(new File("target/SimpleForm.pdf"))) { PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(); // Get the field and the widget associated to it. // Note: there might be multiple widgets PDField field = acroForm.getField("SampleField"); PDAnnotationWidget widget = field.getWidgets().get(0); // Create the definition for a green border PDAppearanceCharacteristicsDictionary fieldAppearance = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); PDColor green = new PDColor(new float[] { 0, 1, 0 }, PDDeviceRGB.INSTANCE); fieldAppearance.setBorderColour(green); // Set the information to be used by the widget which is responsible // for the visual style of the form field. widget.setAppearanceCharacteristics(fieldAppearance); document.save("target/AddBorderToField.pdf"); } } }
radioButton.setExportValues(options); PDAppearanceCharacteristicsDictionary appearanceCharacteristics = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); appearanceCharacteristics.setBorderColour(new PDColor(new float[] { 1, 0, 0 }, PDDeviceRGB.INSTANCE)); appearanceCharacteristics.setBackground(new PDColor(new float[]{0, 1, 0.3f}, PDDeviceRGB.INSTANCE));
= new PDAppearanceCharacteristicsDictionary(new COSDictionary()); fieldAppearance1.setBorderColour(new PDColor(new float[]{0,1,0}, PDDeviceRGB.INSTANCE)); fieldAppearance1.setBackground(new PDColor(new float[]{1,1,0}, PDDeviceRGB.INSTANCE)); = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); fieldAppearance2.setBorderColour(new PDColor(new float[]{1,0,0}, PDDeviceRGB.INSTANCE)); fieldAppearance2.setBackground(new PDColor(new float[]{0,1,0}, PDDeviceRGB.INSTANCE));
widget.setPrinted(true); PDAppearanceCharacteristicsDictionary appearanceCharacteristics = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); appearanceCharacteristics.setBorderColour(new PDColor(new float[]{1, 0, 0}, PDDeviceRGB.INSTANCE)); appearanceCharacteristics.setBackground(new PDColor(new float[]{1, 1, 0}, PDDeviceRGB.INSTANCE));
= new PDAppearanceCharacteristicsDictionary(new COSDictionary()); fieldAppearance.setBorderColour(new PDColor(new float[]{0,1,0}, PDDeviceRGB.INSTANCE)); fieldAppearance.setBackground(new PDColor(new float[]{1,1,0}, PDDeviceRGB.INSTANCE));
/** * Returns the appearance characteristics dictionary. * * @return the appearance characteristics dictionary */ public PDAppearanceCharacteristicsDictionary getAppearanceCharacteristics() { COSBase mk = this.getCOSObject().getDictionaryObject(COSName.MK); if (mk instanceof COSDictionary) { return new PDAppearanceCharacteristicsDictionary((COSDictionary) mk); } return null; }
/** * Returns the appearance characteristics dictionary. * * @return the appearance characteristics dictionary */ public PDAppearanceCharacteristicsDictionary getAppearanceCharacteristics() { COSBase mk = this.getCOSObject().getDictionaryObject(COSName.MK); if (mk instanceof COSDictionary) { return new PDAppearanceCharacteristicsDictionary((COSDictionary) mk); } return null; }
public static void main(String[] args) throws IOException { // Load the PDF document created by SimpleForm.java PDDocument document = PDDocument.load(new File("target/SimpleForm.pdf")); PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(); // Get the field and the widget associated to it. // Note: there might be multiple widgets PDField field = acroForm.getField("SampleField"); PDAnnotationWidget widget = field.getWidgets().get(0); // Create the definition for a green border PDAppearanceCharacteristicsDictionary fieldAppearance = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); PDColor green = new PDColor(new float[] { 0, 1, 0 }, PDDeviceRGB.INSTANCE); fieldAppearance.setBorderColour(green); // Set the information to be used by the widget which is responsible // for the visual style of the form field. widget.setAppearanceCharacteristics(fieldAppearance); document.save("target/AddBorderToField.pdf"); document.close(); } }
PDAppearanceCharacteristicsDictionary appearanceCharacteristics = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); appearanceCharacteristics.setNormalCaption(String.valueOf((char) style.caption)); widget.setAppearanceCharacteristics(appearanceCharacteristics);
PDAppearanceCharacteristicsDictionary appearanceCharacteristics = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); appearanceCharacteristics.setNormalCaption(String.valueOf((char) style.caption)); widget.setAppearanceCharacteristics(appearanceCharacteristics);
= new PDAppearanceCharacteristicsDictionary(new COSDictionary()); fieldAppearance1.setBorderColour(new PDColor(new float[]{0,1,0}, PDDeviceRGB.INSTANCE)); fieldAppearance1.setBackground(new PDColor(new float[]{1,1,0}, PDDeviceRGB.INSTANCE)); = new PDAppearanceCharacteristicsDictionary(new COSDictionary()); fieldAppearance2.setBorderColour(new PDColor(new float[]{1,0,0}, PDDeviceRGB.INSTANCE)); fieldAppearance2.setBackground(new PDColor(new float[]{0,1,0}, PDDeviceRGB.INSTANCE));
= new PDAppearanceCharacteristicsDictionary(new COSDictionary()); fieldAppearance.setBorderColour(new PDColor(new float[]{0,1,0}, PDDeviceRGB.INSTANCE)); fieldAppearance.setBackground(new PDColor(new float[]{1,1,0}, PDDeviceRGB.INSTANCE));