Because object numbering and their location in a PDF are completely free form – 
there are no requirements.

Why does it matter?

From: Alvaro Cuno <[email protected]<mailto:[email protected]>>
Reply-To: Post here 
<[email protected]<mailto:[email protected]>>
To: Post here 
<[email protected]<mailto:[email protected]>>
Subject: [iText-questions] are the dictionary elements randomly placed?


Hello all,

I signed a same file (hello.pdf) three times using the next code:

    public static void sign(String src, String dest)
            throws IOException, DocumentException, KeyStoreException,
            NoSuchAlgorithmException, CertificateException, 
UnrecoverableKeyException {

        Security.addProvider(new BouncyCastleProvider());
        KeyStore ks = KeyStore.getInstance("pkcs12");
        ks.load(new FileInputStream("citizen1.p12"), "password".toCharArray());
        String alias = (String) ks.aliases().nextElement();
        PrivateKey key = (PrivateKey) ks.getKey(alias, 
"password".toCharArray());
        Certificate[] chain = ks.getCertificateChain(alias);

        PdfReader reader = new PdfReader(src);
        FileOutputStream os = new FileOutputStream(dest);
        PdfStamper stamper = PdfStamper.createSignature(reader, os, '\0', null, 
true);
        PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
        appearance.setAcro6Layers(true);
        appearance.setCrypto(key, chain, null, 
PdfSignatureAppearance.WINCER_SIGNED);
        appearance.setVisibleSignature(new Rectangle(160, 732, 232, 780), 1, 
null);
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date(0));
appearance.setSignDate(cal);
        stamper.close();
    }

Everything is ok and all digital signatures are valid, however I don't 
understand why the internal structures of the signed documents (see attached 
files) are different?


hello-signed-1.pdf      hello-signed-2.pdf       hello-signed-3.pdf
   ...                              ...                            ...
   %%EOF                    %%EOF                   %%EOF
   ...                              ...                            ...
   10 0 obj                      10 0 obj                    10 0 obj
   11 0 obj                        8 0 obj                    11 0 obj
   12 0 obj                      11 0 obj                    12 0 obj
    8 0 obj                        9 0 obj                      9 0 obj
    9 0 obj                      12 0 obj                      8 0 obj
    5 0 obj                        5 0 obj                      5 0 obj
   ...                              ...                             ...


The objects 8, 9 and 11 are related to /n0, /n2, /FRM  fields, ... these were 
inserted randomly? if yes, why?

-
Alvaro

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]
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