AcroFields { public boolean setField(String name, String value) throws IOException, DocumentException { return setField(name, value, null); } AcroFields(PdfReader reader, PdfWriter writer); static Object[] splitDAelements(String da); String[] getAppearanceStates(String fieldName); String[] getListOptionExport(String fieldName); String[] getListOptionDisplay(String fieldName); boolean setListOption(String fieldName, String[] exportValues, String[] displayValues); int getFieldType(String fieldName); void exportAsFdf(FdfWriter writer); boolean renameField(String oldName, String newName); void decodeGenericDictionary(PdfDictionary merged, BaseField tx); String getFieldRichValue(String name); String getField(String name); String[] getListSelection(String name); boolean setFieldProperty(String field, String name, Object value, int inst[]); boolean setFieldProperty(String field, String name, int value, int inst[]); void mergeXfaData(Node n); void setFields(FdfReader fdf); boolean regenerateField(String name); boolean setField(String name, String value); boolean setField(String name, String value, boolean saveAppearance); boolean setFieldRichValue(String name, String richValue); boolean setField(String name, String value, String display); boolean setField(String name, String value, String display, boolean saveAppearance); boolean setListSelection(String name, String[] value); Map<String, Item> getFields(); void setFields(XfdfReader xfdf); Item getFieldItem(String name); String getTranslatedFieldName(String name); List<FieldPosition> getFieldPositions(String name); boolean removeFieldsFromPage(int page); boolean removeField(String name, int page); boolean removeField(String name); boolean isGenerateAppearances(); void setGenerateAppearances(boolean generateAppearances); boolean clearSignatureField(String name); ArrayList<String> getSignatureNames(); ArrayList<String> getBlankSignatureNames(); PdfDictionary getSignatureDictionary(String name); PdfIndirectReference getNormalAppearance(String name); boolean signatureCoversWholeDocument(String name); PdfPKCS7 verifySignature(String name); PdfPKCS7 verifySignature(String name, String provider); int getTotalRevisions(); int getRevision(String field); InputStream extractRevision(String field); Map<String, TextField> getFieldCache(); void setFieldCache(Map<String, TextField> fieldCache); void setExtraMargin(float extraMarginLeft, float extraMarginTop); void addSubstitutionFont(BaseFont font); ArrayList<BaseFont> getSubstitutionFonts(); void setSubstitutionFonts(ArrayList<BaseFont> substitutionFonts); XfaForm getXfa(); void removeXfa(); PushbuttonField getNewPushbuttonFromField(String field); PushbuttonField getNewPushbuttonFromField(String field, int order); boolean replacePushbuttonField(String field, PdfFormField button); boolean replacePushbuttonField(String field, PdfFormField button, int order); boolean doesSignatureFieldExist(String name); static final int DA_FONT; static final int DA_SIZE; static final int DA_COLOR; static final int FIELD_TYPE_NONE; static final int FIELD_TYPE_PUSHBUTTON; static final int FIELD_TYPE_CHECKBOX; static final int FIELD_TYPE_RADIOBUTTON; static final int FIELD_TYPE_TEXT; static final int FIELD_TYPE_LIST; static final int FIELD_TYPE_COMBO; static final int FIELD_TYPE_SIGNATURE; }
@Test public void icelandicLettersInAcroFieldTest() throws IOException, DocumentException, InterruptedException { String outFile = outFolder + "icelandicLettersInAcroFieldTest.pdf"; FileOutputStream file = new FileOutputStream(outFile); PdfReader reader = new PdfReader(new FileInputStream(sourceFolder + "HelveticaFont.pdf")); PdfStamper stamper = new PdfStamper(reader, file); AcroFields fields = stamper.getAcroFields(); fields.setField("Mitarbeiter", "ÁÁÁÁ ÓÓÓÓ Testð"); stamper.close(); CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outFile, sourceFolder + "cmp_icelandicLettersInAcroFieldTest.pdf", outFolder, "diff_"); if (errorMessage != null) { Assert.fail(errorMessage); } }
@Test public void specialCharactersInAcroFieldTest() throws IOException, DocumentException, InterruptedException { String outFile = outFolder + "specialCharactersInAcroFieldTest.pdf"; FileOutputStream file = new FileOutputStream(outFile); PdfReader reader = new PdfReader(new FileInputStream(sourceFolder + "HelveticaFont.pdf")); PdfStamper stamper = new PdfStamper(reader, file); AcroFields acroFields = stamper.getAcroFields(); acroFields.setField("Mitarbeiter", "öäüß€@"); stamper.close(); CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outFile, sourceFolder + "cmp_specialCharactersInAcroFieldTest.pdf", outFolder, "diff_"); if (errorMessage != null) { Assert.fail(errorMessage); } }
@Test public void flatteningRadioButtonFields1() throws IOException, DocumentException, InterruptedException { String outFile = outFolder + "flatteningRadioButtonFields1.pdf"; FileOutputStream file = new FileOutputStream(outFile); PdfReader reader = new PdfReader(new FileInputStream(sourceFolder + "radios_src1.pdf")); PdfStamper stamper = new PdfStamper(reader, file); AcroFields acroFields = stamper.getAcroFields(); acroFields.setField("radiogroup", "1"); stamper.close(); CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outFile, sourceFolder + "cmp_flatteningRadioButtonFields1.pdf", outFolder, "diff_"); if (errorMessage != null) { Assert.fail(errorMessage); } }
@Test public void flatteningRadioButtonFields2() throws IOException, DocumentException, InterruptedException { String outFile = outFolder + "flatteningRadioButtonFields2.pdf"; FileOutputStream file = new FileOutputStream(outFile); PdfReader reader = new PdfReader(new FileInputStream(sourceFolder + "radios_src2.pdf")); PdfStamper stamper = new PdfStamper(reader, file); AcroFields acroFields = stamper.getAcroFields(); acroFields.setField("radiogroup", "1"); stamper.close(); CompareTool compareTool = new CompareTool(); String errorMessage = compareTool.compareByContent(outFile, sourceFolder + "cmp_flatteningRadioButtonFields2.pdf", outFolder, "diff_"); if (errorMessage != null) { Assert.fail(errorMessage); } }