List of usage examples for com.lowagie.text.pdf PdfName V
PdfName V
To view the source code for com.lowagie.text.pdf PdfName V.
Click Source Link
From source file:org.opensignature.opensignpdf.PDFSigner.java
License:Open Source License
/** * //w w w.j a va 2 s. co m * @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/*from w ww . j a va 2s .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); } }
From source file:questions.markedcontent.ObjectData.java
public static void main(String[] args) { Document document = new Document(PageSize.A5.rotate()); try {//from w w w. jav a 2 s. c o m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); writer.setTagged(); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfStructureTreeRoot tree = writer.getStructureTreeRoot(); PdfStructureElement se = new PdfStructureElement(tree, new PdfName("Figure")); PdfStructureElement element = new PdfStructureElement(se, new PdfName("Element")); PdfDictionary userproperties = new PdfDictionary(); userproperties.put(PdfName.O, PdfName.USERPROPERTIES); userproperties.put(PdfName.S, new PdfName("Figure")); PdfArray properties = new PdfArray(); PdfDictionary property1 = new PdfDictionary(); property1.put(PdfName.N, new PdfString("Name1")); property1.put(PdfName.V, new PdfString("Value1")); properties.add(property1); PdfDictionary property2 = new PdfDictionary(); property2.put(PdfName.N, new PdfString("Name2")); property2.put(PdfName.V, new PdfString("Value2")); properties.add(property2); PdfDictionary property3 = new PdfDictionary(); property3.put(PdfName.N, new PdfString("Name3")); property3.put(PdfName.V, new PdfString("Value3")); properties.add(property3); userproperties.put(PdfName.P, properties); element.put(PdfName.A, userproperties); PdfLayer lay1 = new PdfLayer("My object", writer); cb.beginMarkedContentSequence(element); cb.beginLayer(lay1); cb.setColorFill(Color.BLUE); cb.rectangle(50, 50, 200, 200); cb.fill(); cb.endLayer(); cb.endMarkedContentSequence(); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }