You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Ishan Pandya <i_...@yahoo.co.in.INVALID> on 2016/08/17 12:07:00 UTC

Need help with setCanExtractContent method

Hi All Devs, 
We are using PDFBox for evaluation purpose and are testing encryption / decryption functionality of yours. We have observed a scenario when encrypting a document that even when setting the setCanExtractContent() to true, the copy command does not show up in acrobat readers. But when I open the PDF using owner password, the copy command shows up properly. 
The scenario means, if I allow the user who has user password to allow setCanExtractContent to true, he should be able to copy the content via PDF Reader applications like Abrobat Reader. Please find below sample code of the scenario:
AccessPermission ap = new AccessPermission();ap.setCanExtractContent(permissions.Copy);
StandardProtectionPolicy spp = new StandardProtectionPolicy(ownerPassword, userPassword);spp.setEncryptionKeyLength(keyLength);spp.setPreferAES(preferAES);spp.setPermissions(ap);doc.protect(spp);doc.save(outputFile);doc.close(); 
Can someone guide me with this scenario if I am doing anything wrong or so.
Thanks in advance. Your help is much appriciated.  
 Regards,
Ishan Pandya


Re: Need help with setCanExtractContent method

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 22.08.2016 um 08:02 schrieb i_y_pandya@yahoo.co.in:
> Hi Tilman,
>
> Thank you for your email. My apologies for not mentioning the PDFBox version. Please find below information to the version,
>
> PDFBox Version Info : 2.0.0
> Link to the code :
> http://pastie.org/private/1j18lbkhpac3wiolmgoqka
>
> Used for: C# via IKVM,
>
> Also, the the Permissions.Copy is true when we want it to be true. However, even if it returns true, the copy permissions do not reflect for the user of the PDF.

Hello,

- Your code looks OK, although you're setting the permission twice 
("spp.setPermissions(ap);") but this is harmless
- the current version is 2.0.2, not 2.0.0, so please test again with the 
current version.
- you're using the C# but PDFBox is a java product. The C# IKVM build 
isn't supported by us. Of course we'd want to fix bugs, but only if they 
happen in the java build.
- calling "setAllSecurityToBeRemoved(true);" doesn't make sense...this 
was fixed in PDFBOX-2888, this was before 2.0.0 (but maybe you're using 
2.0.0 RC ? Please check this. And please, please, use the current version)
- check your logs if you get any warnings. Calling 
"setAllSecurityToBeRemoved(true);" before encrypting does bring out a 
warning. If you don't see it, then you're log doesn't work or you're not 
using 2.0.0.

The warning is

"do not call setAllSecurityToBeRemoved(true) before calling protect(), 
as protect() implies setAllSecurityToBeRemoved(false)"

- "doc.getDocument().setDecrypted();" is not needed either.


What you could also do is this:
- run your program on a non-confidential file. Then check what happens, 
and if the result is bad, then upload the source and the result PDF.
- if possible, do the same with a java programme.
- if the result is good, then try to find out if the result is bad only 
for certain files? (run it on a file that has already been encrypted, 
and on one that wasn't encrypted before)

Tilman



>
> awaiting your prompt response.
>
> Regards,
> Ishan P.
>
>
>
> On 2016-08-17 22:38 (+0530), Tilman Hausherr <TH...@t-online.de> wrote:
>> Am 17.08.2016 um 14:07 schrieb Ishan Pandya:
>>> Hi All Devs,
>>> We are using PDFBox for evaluation purpose and are testing encryption / decryption functionality of yours. We have observed a scenario when encrypting a document that even when setting the setCanExtractContent() to true, the copy command does not show up in acrobat readers. But when I open the PDF using owner password, the copy command shows up properly.
>>> The scenario means, if I allow the user who has user password to allow setCanExtractContent to true, he should be able to copy the content via PDF Reader applications like Abrobat Reader. Please find below sample code of the scenario:
>>> AccessPermission ap = new AccessPermission();ap.setCanExtractContent(permissions.Copy);
>>> StandardProtectionPolicy spp = new StandardProtectionPolicy(ownerPassword, userPassword);spp.setEncryptionKeyLength(keyLength);spp.setPreferAES(preferAES);spp.setPermissions(ap);doc.protect(spp);doc.save(outputFile);doc.close();
>>> Can someone guide me with this scenario if I am doing anything wrong or so.
>>> Thanks in advance. Your help is much appriciated.
>>>    Regards,
>>> Ishan Pandya
>> Same answer as last time:
>>
>>
>> Please mention what version you are using, and upload the "protected"
>> file on a sharehoster, and post the link.
>>
>>
>> Make sure that "permissions.Copy" is really true at runtime.
>>
>>
>> Tilman
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


Re: Need help with setCanExtractContent method

Posted by "i_y_pandya@yahoo.co.in" <i_...@yahoo.co.in>.
Hi Tilman,

Thank you for your email. My apologies for not mentioning the PDFBox version. Please find below information to the version, 

PDFBox Version Info : 2.0.0
Link to the code : 
http://pastie.org/private/1j18lbkhpac3wiolmgoqka

Used for: C# via IKVM,

Also, the the Permissions.Copy is true when we want it to be true. However, even if it returns true, the copy permissions do not reflect for the user of the PDF. 

awaiting your prompt response.  

Regards,
Ishan P.



On 2016-08-17 22:38 (+0530), Tilman Hausherr <TH...@t-online.de> wrote: 
> Am 17.08.2016 um 14:07 schrieb Ishan Pandya:
> > Hi All Devs,
> > We are using PDFBox for evaluation purpose and are testing encryption / decryption functionality of yours. We have observed a scenario when encrypting a document that even when setting the setCanExtractContent() to true, the copy command does not show up in acrobat readers. But when I open the PDF using owner password, the copy command shows up properly.
> > The scenario means, if I allow the user who has user password to allow setCanExtractContent to true, he should be able to copy the content via PDF Reader applications like Abrobat Reader. Please find below sample code of the scenario:
> > AccessPermission ap = new AccessPermission();ap.setCanExtractContent(permissions.Copy);
> > StandardProtectionPolicy spp = new StandardProtectionPolicy(ownerPassword, userPassword);spp.setEncryptionKeyLength(keyLength);spp.setPreferAES(preferAES);spp.setPermissions(ap);doc.protect(spp);doc.save(outputFile);doc.close();
> > Can someone guide me with this scenario if I am doing anything wrong or so.
> > Thanks in advance. Your help is much appriciated.
> >   Regards,
> > Ishan Pandya
> 
> Same answer as last time:
> 
> 
> Please mention what version you are using, and upload the "protected" 
> file on a sharehoster, and post the link.
> 
> 
> Make sure that "permissions.Copy" is really true at runtime.
> 
> 
> Tilman
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Need help with setCanExtractContent method

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 17.08.2016 um 14:07 schrieb Ishan Pandya:
> Hi All Devs,
> We are using PDFBox for evaluation purpose and are testing encryption / decryption functionality of yours. We have observed a scenario when encrypting a document that even when setting the setCanExtractContent() to true, the copy command does not show up in acrobat readers. But when I open the PDF using owner password, the copy command shows up properly.
> The scenario means, if I allow the user who has user password to allow setCanExtractContent to true, he should be able to copy the content via PDF Reader applications like Abrobat Reader. Please find below sample code of the scenario:
> AccessPermission ap = new AccessPermission();ap.setCanExtractContent(permissions.Copy);
> StandardProtectionPolicy spp = new StandardProtectionPolicy(ownerPassword, userPassword);spp.setEncryptionKeyLength(keyLength);spp.setPreferAES(preferAES);spp.setPermissions(ap);doc.protect(spp);doc.save(outputFile);doc.close();
> Can someone guide me with this scenario if I am doing anything wrong or so.
> Thanks in advance. Your help is much appriciated.
>   Regards,
> Ishan Pandya

Same answer as last time:


Please mention what version you are using, and upload the "protected" 
file on a sharehoster, and post the link.


Make sure that "permissions.Copy" is really true at runtime.


Tilman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org