List of usage examples for com.lowagie.text.pdf PdfName DV
PdfName DV
To view the source code for com.lowagie.text.pdf PdfName DV.
Click Source Link
From source file:org.opensignature.opensignpdf.PDFSigner.java
License:Open Source License
/** * //from w w w .j a v a 2 s . com * @param pdfFile * @return * @throws IOException * @throws DocumentException * @throws FileNotFoundException */ private PdfReader createPDFReader(File pdfFile) throws IOException, DocumentException, FileNotFoundException { logger.info("[createPDFReader.in]:: " + Arrays.asList(new Object[] { pdfFile })); PdfReader reader; if ("true".equals(openOfficeSelected)) { String fileName = pdfFile.getPath(); String tempFileName = fileName + ".temp"; PdfReader documentPDF = new PdfReader(fileName); PdfStamperOSP stamperTemp = new PdfStamperOSP(documentPDF, new FileOutputStream(tempFileName)); AcroFields af = stamperTemp.getAcroFields(); af.setGenerateAppearances(true); PdfDictionary acro = (PdfDictionary) PdfReader .getPdfObject(documentPDF.getCatalog().get(PdfName.ACROFORM)); acro.remove(PdfName.DR); HashMap fields = af.getFields(); String key; for (Iterator it = fields.keySet().iterator(); it.hasNext();) { key = (String) it.next(); int a = af.getFieldType(key); if (a == 4) { ArrayList widgets = af.getFieldItem(key).widgets; PdfDictionary widget = (PdfDictionary) widgets.get(0); widget.put(PdfName.FT, new PdfName("Sig")); widget.remove(PdfName.V); widget.remove(PdfName.DV); widget.remove(PdfName.TU); widget.remove(PdfName.FF); widget.remove(PdfName.DA); widget.remove(PdfName.DR); widget.remove(PdfName.AP); } } stamperTemp.close(); documentPDF.close(); reader = new PdfReader(pdfFile.getPath() + ".temp"); } else { reader = new PdfReader(pdfFile.getPath()); } logger.info("[createPDFReader.retorna]:: "); return reader; }
From source file:org.squale.welcom.outils.pdf.advanced.WPdfFieldReader.java
License:Open Source License
/** * init// ww w. j a v a2s. c o m */ public void init() { for (int i = 0; i < pdfReader.getAcroForm().size(); i++) { final PRAcroForm.FieldInformation p = (PRAcroForm.FieldInformation) pdfReader.getAcroForm().getFields() .get(i); final WPdfField pf = new WPdfField(); pf.setName(p.getName()); // Si ce n'est pas un champs text alors on l'ignore if (!p.getInfo().contains(PdfName.FT) || !(((PdfName) p.getInfo().get(PdfName.FT)).toString().equals(PdfName.TX.toString()))) { pf.setType(WPdfFieldType.INCONNU); } else { if (p.getInfo().contains(PdfName.DV)) { pf.setDefaultValue(((PdfString) (p.getInfo().get(PdfName.DV))).toUnicodeString()); } if (p.getInfo().contains(PdfName.V)) { pf.setValue(((PdfString) (p.getInfo().get(PdfName.V))).toUnicodeString()); } if (p.getInfo().contains(PdfName.FF)) { final PdfNumber pn = (PdfNumber) p.getInfo().get(PdfName.FF); if ((pn.intValue() & PdfFormField.FF_MULTILINE) == PdfFormField.FF_MULTILINE) { pf.setType(WPdfFieldType.MUTILINETEXT); } else { pf.setType(WPdfFieldType.TEXT); } } else { pf.setType(WPdfFieldType.TEXT); } } fields.add(pf); } }