pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Diphoorn <martindipho...@gmail.com>
Subject Problems with signing and permissions
Date Mon, 18 Nov 2013 18:11:58 GMT
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);

AccessPermission ap = new AccessPermission();

StandardProtectionPolicy spp = new StandardProtectionPolicy(null, null, ap);


doc.saveIncremental(fis, fos);

<End code>

Am i missing something?

Thanks in advance,

Martin Diphoorn

View raw message