Yes i found it here, but don't store the data. I write here what I've done:

if(!file.exists()){
        Document document = new Document();
        FileOutputStream os = new FileOutputStream("prova.pdf");
        try {
                writer = PdfWriter.getInstance(document, os);
                document.open();
                document.add(new 
Paragraph("prova\nprova\nprova\nprova\nprova"));
                document.addHeader("header", "prova header");
                path = path.replace("tiff.tif", "signatureresize.bmp");
                Image image1 = Image.getInstance(path);
                image1.setAlignment(Element.ALIGN_RIGHT);
                document.add(image1);
        } catch (DocumentException | IOException e) {
                e.printStackTrace();
        }
        document.close();
                
        PdfName appName = new PdfName("MYAPP");
        PdfName dataName = new PdfName("Hash");

         DocumentPieceInfo dpi = new DocumentPieceInfo();

        PdfReader reader = new PdfReader("prova.pdf");
        dpi.addPieceInfo(os, reader, appName, dataName, new PdfString("prova"));

        PdfStamper stamper = new PdfStamper(reader, os);
        PdfObject obj = dpi.getPieceInfo(reader, appName, dataName);
        System.out.println((obj==null)?"null":obj.toString());
        PdfDictionary catalog = reader.getCatalog();
        Set<PdfName> prova = catalog.getKeys();
        System.out.println(prova.toString());

       //output when i create the pdf and insert the dictionary is:
       //prova
       //[/Type, /PieceInfo, /Pages]

}else{
         PdfName appName = new PdfName("MYAPP");
        PdfName dataName = new PdfName("Hash");

        DocumentPieceInfo dpi = new DocumentPieceInfo();

         PdfReader reader = new PdfReader("prova.pdf");
         PdfObject myData = dpi.getPieceInfo(reader, appName, dataName);
         System.out.println((myData==null)?"null":myData.toString());
         PdfDictionary catalog = reader.getCatalog();
         Set<PdfName> prova = catalog.getKeys();
        System.out.println(prova.toString());

        //the output for this section is:
        //null
        //[/Type, /Pages]
}
  
Sorry, maybe I don't understand how use this class.



--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Insert-custom-dictionary-in-pdf-file-tp4659026p4659029.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to