pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Chojecki <i...@rayman2200.de>
Subject Re: Problems with signing and permissions
Date Mon, 18 Nov 2013 19:07:11 GMT
Hallo Martin,
Encryption and other features that need to manipulate the whole document, does not work with
the saveIncremental(). Right know it isn't possible to write a signature using save() only.


Signing with permissions not work.

Best regards
Thomas

Martin Diphoorn <martindiphoorn@gmail.com> schrieb:

>Hi all,
>
>i have been searching for some hours on google today to find the answer, 
>but i was unable to find it.
>
>I have a PDF just created with FOP.
>
>I have written the file to disk without any permissions set. When i come 
>to the sign process i set the right permissions and add the certificate 
>setting for signing the PDF. However i always get an PDF which needs an 
>password, but i did not set one. If i set an PDF it will never accept it.
>
>I did take the following steps.
>
>1. Create an signed PDF and save with doc.saveIncremental. Everything 
>wend well.
>
>2. Create an encrypted PDF without an password with permissions using 
>doc.save(). No problems.
>
>3. Create an encrypted PDF without an password with permissions using 
>doc.saveIncremental(). NOT working.
>
>(2 and 3 is without any signing, thats the next step.)
>
>Some stripped code:
><start code>
>PDDocument doc = PDDocument.load(document);
>
>FileInputStream fis = new FileInputStream(document);
>FileOutputStream fos = new FileOutputStream(outputDocument);
>
>int c;
>while ((c = fis.read(buffer)) != -1) {
>      fos.write(buffer, 0, c);
>  }
>  fis.close();
>
>AccessPermission ap = new AccessPermission();
>ap.setCanModify(false);
>
>StandardProtectionPolicy spp = new StandardProtectionPolicy(null, null, ap);
>
>doc.protect(spp);
>
>doc.saveIncremental(fis, fos);
>//doc.save(fos);
>
><End code>
>
>Am i missing something?
>
>Thanks in advance,
>
>Martin Diphoorn
Mime
View raw message