PDF is password protected although no password was specified

View: New views
16 Messages — Rating Filter:   Alert me  

PDF is password protected although no password was specified

by 3melie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am programmatically rendering a pdf document from XSL-FO using FOP and now I want to disable copying and editing in it.

I am setting my encryption-params, but although I am not specifying a user password the file produced says it is password protected and it is asking for a password.

I ve tried:

foUserAgent.getRendererOptions().put("encryption-params", new PDFEncryptionParams( "password", "", true, false, false, false));

foUserAgent.getRendererOptions().put("encryption-params", new PDFEncryptionParams( "password", null, true, false, false, false));

and also

PDFEncryptionParams params = new PDFEncryptionParams();
params.setOwnerPassword("password");
params.setAllowCopyContent(false);
params.setAllowEditContent(false)
params.setAllowEditAnnotations(false);
foUserAgent.getRendererOptions().put("encryption-params", params);

Am I doing something wrong?
               

Re: PDF document asking

by Andreas Delmelle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 28 May 2009, at 13:42, 3melie wrote:

Hi

> I am programmatically rendering a pdf document from XSL-FO using FOP  
> and now
> I want to disable copying and editing in it.
>
> I am setting my encryption-params, but although I am not specifying  
> a user
> password the file produced says it is password protected and it is  
> asking
> for a password.
>
> I ve tried:
> <snip />
> Am I doing something wrong?

The samples you provided set the user password, which triggers the  
dialog. The user password can be left blank if you want to avoid this,  
but the sample code you provided leaves the owner password blank and  
sets the user password to "password".

see: http://xmlgraphics.apache.org/fop/0.95/pdfencryption.html
Under 'Usage (embedded)' you can find the parameter definitions. The  
first parameter is the user password, the second is the owner password.


HTH!

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document asking

by 3melie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I ve also tried:

        foUserAgent.getRendererOptions().put("encryption-params",
                                new PDFEncryptionParams( null, null, true, false, false, false));

but it still says the PDF is password protected.


Andreas Delmelle-2 wrote:
On 28 May 2009, at 13:42, 3melie wrote:

Hi

> I am programmatically rendering a pdf document from XSL-FO using FOP  
> and now
> I want to disable copying and editing in it.
>
> I am setting my encryption-params, but although I am not specifying  
> a user
> password the file produced says it is password protected and it is  
> asking
> for a password.
>
> I ve tried:
> <snip />
> Am I doing something wrong?

The samples you provided set the user password, which triggers the  
dialog. The user password can be left blank if you want to avoid this,  
but the sample code you provided leaves the owner password blank and  
sets the user password to "password".

see: http://xmlgraphics.apache.org/fop/0.95/pdfencryption.html
Under 'Usage (embedded)' you can find the parameter definitions. The  
first parameter is the user password, the second is the owner password.


HTH!

Andreas

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

Re: PDF document asking

by Adrian Wiesmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all

3melie <thanou.anna@...> wrote:

> I am programmatically rendering a pdf document from XSL-FO using FOP and
> now I want to disable copying and editing in it.

Just so that there is no bad awakening: Many of these features are
enforced by the viewer application and not the PDF. Which means that users
can do whatever they want to do with your PDF as long as their application
does not enforce these settings. And there are plenty of tools which do
not enforce them.

This is not true for encryption and signing, but for printing, extracting,
etc.

Cheers,
Adrian

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document asking

by Andreas Delmelle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 28 May 2009, at 14:05, 3melie wrote:

>
> I ve also tried:
>
> foUserAgent.getRendererOptions().put("encryption-params",
> new PDFEncryptionParams( null, null, true, false, false, false));
>
> but it still says the PDF is password protected.

OK, but do you still have to enter a password? That the file is  
password-protected is normal, since the print- and copy-restrictions  
require at least the owner password.

Come to think of it, which FOP version are you using. I seem to  
remember an issue that got fixed in FOP Trunk, where the PDF document  
trailer ended up having two /ID entries in case encryption was used.  
Some Acrobat versions and other PDF viewers were confused by this.


HTH!

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document asking

by 3melie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Andrea & Adrian,

Thank you very much for your answers.

I am using fop-0.95

What I d like to do is to disable copying and editing of the PDF but withought having the file password protected.
Is this possible?


Emelie

Andreas Delmelle-2 wrote:
On 28 May 2009, at 14:05, 3melie wrote:

>
> I ve also tried:
>
> foUserAgent.getRendererOptions().put("encryption-params",
> new PDFEncryptionParams( null, null, true, false, false, false));
>
> but it still says the PDF is password protected.

OK, but do you still have to enter a password? That the file is  
password-protected is normal, since the print- and copy-restrictions  
require at least the owner password.

Come to think of it, which FOP version are you using. I seem to  
remember an issue that got fixed in FOP Trunk, where the PDF document  
trailer ended up having two /ID entries in case encryption was used.  
Some Acrobat versions and other PDF viewers were confused by this.


HTH!

Andreas


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

Re: PDF document asking

by Andreas Delmelle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 28 May 2009, at 14:26, 3melie wrote:

Hi

> Thank you very much for your answers.
>
> I am using fop-0.95
>
> What I d like to do is to disable copying and editing of the PDF but
> withought having the file password protected.
> Is this possible?

Yes, but due to the mentioned issue (which still exists in 0.95) this  
may not work in some versions of Adobe Reader, and I know Preview on  
Mac OS has problems with that too. It depends on which /ID entry the  
viewer application actually uses.

If one leaves the user password blank, that should normally suffice to  
impose no restrictions on viewing.

Not sure if it is a possibility for you to download and build FOP  
Trunk. If you have Subversion and Ant available on your system, then  
it requires virtually no extra effort. Just check out with Subversion,  
navigate to FOP's root directory in a terminal window, and run 'ant  
package' to create the fop.jar.

see also: http://xmlgraphics.apache.org/fop/download.html#source


HTH!

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document asking

by Andreas Delmelle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 28 May 2009, at 15:07, Andreas Delmelle wrote:

> <snip />

> Not sure if it is a possibility for you to download and build FOP  
> Trunk. If you have Subversion and Ant available on your system, then  
> it requires virtually no extra effort.

Forgot to mention: to build FOP, one obviously also needs a Java  
Development Kit (JDK). A simple Java Runtime (JRE), which is mostly  
available on newer systems, is not enough to compile Java sources.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document asking

by Sergiu Dumitriu-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andreas Delmelle wrote:
> Not sure if it is a possibility for you to download and build FOP Trunk.
> If you have Subversion and Ant available on your system, then it
> requires virtually no extra effort. Just check out with Subversion,
> navigate to FOP's root directory in a terminal window, and run 'ant
> package' to create the fop.jar.

Not exactly, I had some problems when trying this on the command line,
but it worked from Eclipse.

> init-avail:
>      [echo] ------------------- Apache FOP svn-trunk [1999-2009] ----------------
>      [echo] See build.properties and build-local.properties for additional build settings
>      [echo] Apache Ant version 1.7.1 compiled on May 25 2009
>      [echo] VM: 11.3-b02, Sun Microsystems Inc.
>      [echo] JAVA_HOME: /opt/sun-jdk-1.6.0.13
>      [echo] JAI Support PRESENT
>      [echo] JCE Support PRESENT
>      [echo] JUnit Support PRESENT
>      [echo] XMLUnit Support PRESENT
>
> init:
>
> codegen:
>      [echo] Generating the java files from xml resources
>
> compile-java:
>
> resourcegen:
>
> BUILD FAILED
> java.lang.NullPointerException
>         at org.apache.fop.tools.EventProducerCollector.createMethodModel(EventProducerCollector.java:138)
>         at org.apache.fop.tools.EventProducerCollector.processEventProducerInterface(EventProducerCollector.java:128)
>         at org.apache.fop.tools.EventProducerCollector.scanFile(EventProducerCollector.java:98)
>         at org.apache.fop.tools.EventProducerCollectorTask.processFileSets(EventProducerCollectorTask.java:189)
>         at org.apache.fop.tools.EventProducerCollectorTask.execute(EventProducerCollectorTask.java:66)
>         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
>         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
>         at org.apache.tools.ant.Task.perform(Task.java:348)
>         at org.apache.tools.ant.Target.execute(Target.java:357)
>         at org.apache.tools.ant.Target.performTasks(Target.java:385)
>         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>         at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>         at org.apache.tools.ant.Main.runBuild(Main.java:758)
>         at org.apache.tools.ant.Main.startAnt(Main.java:217)
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>

--
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document asking

by Andreas Delmelle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 28 May 2009, at 15:46, Sergiu Dumitriu wrote:

> Andreas Delmelle wrote:
>> Not sure if it is a possibility for you to download and build FOP  
>> Trunk. If you have Subversion and Ant available on your system,  
>> then it requires virtually no extra effort. Just check out with  
>> Subversion, navigate to FOP's root directory in a terminal window,  
>> and run 'ant package' to create the fop.jar.
>
> Not exactly, I had some problems when trying this on the command  
> line, but it worked from Eclipse.
>> <snip />
>> codegen:
>>     [echo] Generating the java files from xml resources
>> compile-java:
>> resourcegen:
>> BUILD FAILED
>> java.lang.NullPointerException
>>        at  
>> org
>> .apache
>> .fop
>> .tools
>> .EventProducerCollector
>> .createMethodModel(EventProducerCollector.java:138)

Seems that QDox' JavaMethod.isReturns() may produce null in some  
cases, which results in Type.isVoid() yielding a NPE. Their API docs  
do not offer a lot of explanation, unfortunately....

Do you have another version of QDox in the classpath? Does Eclipse use  
the exact same Java version/build?

Regards

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document asking

by 3melie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I got some problems downloading the Trunk (svn: Unrecognized URL scheme for 'http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk') but i ll try to build the FOP trunk to see if the problem goes away.

Thank you very much for your answers.


Sergiu Dumitriu-2 wrote:
Andreas Delmelle wrote:
> Not sure if it is a possibility for you to download and build FOP Trunk.
> If you have Subversion and Ant available on your system, then it
> requires virtually no extra effort. Just check out with Subversion,
> navigate to FOP's root directory in a terminal window, and run 'ant
> package' to create the fop.jar.

Not exactly, I had some problems when trying this on the command line,
but it worked from Eclipse.

> init-avail:
>      [echo] ------------------- Apache FOP svn-trunk [1999-2009] ----------------
>      [echo] See build.properties and build-local.properties for additional build settings
>      [echo] Apache Ant version 1.7.1 compiled on May 25 2009
>      [echo] VM: 11.3-b02, Sun Microsystems Inc.
>      [echo] JAVA_HOME: /opt/sun-jdk-1.6.0.13
>      [echo] JAI Support PRESENT
>      [echo] JCE Support PRESENT
>      [echo] JUnit Support PRESENT
>      [echo] XMLUnit Support PRESENT
>
> init:
>
> codegen:
>      [echo] Generating the java files from xml resources
>
> compile-java:
>
> resourcegen:
>
> BUILD FAILED
> java.lang.NullPointerException
>         at org.apache.fop.tools.EventProducerCollector.createMethodModel(EventProducerCollector.java:138)
>         at org.apache.fop.tools.EventProducerCollector.processEventProducerInterface(EventProducerCollector.java:128)
>         at org.apache.fop.tools.EventProducerCollector.scanFile(EventProducerCollector.java:98)
>         at org.apache.fop.tools.EventProducerCollectorTask.processFileSets(EventProducerCollectorTask.java:189)
>         at org.apache.fop.tools.EventProducerCollectorTask.execute(EventProducerCollectorTask.java:66)
>         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
>         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
>         at org.apache.tools.ant.Task.perform(Task.java:348)
>         at org.apache.tools.ant.Target.execute(Target.java:357)
>         at org.apache.tools.ant.Target.performTasks(Target.java:385)
>         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>         at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>         at org.apache.tools.ant.Main.runBuild(Main.java:758)
>         at org.apache.tools.ant.Main.startAnt(Main.java:217)
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>

--
Sergiu Dumitriu
http://purl.org/net/sergiu/

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

Re: PDF document asking

by Sergiu Dumitriu-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andreas Delmelle wrote:

> On 28 May 2009, at 15:46, Sergiu Dumitriu wrote:
>
>> Andreas Delmelle wrote:
>>> Not sure if it is a possibility for you to download and build FOP
>>> Trunk. If you have Subversion and Ant available on your system, then
>>> it requires virtually no extra effort. Just check out with
>>> Subversion, navigate to FOP's root directory in a terminal window,
>>> and run 'ant package' to create the fop.jar.
>>
>> Not exactly, I had some problems when trying this on the command line,
>> but it worked from Eclipse.
>>> <snip />
>>> codegen:
>>>     [echo] Generating the java files from xml resources
>>> compile-java:
>>> resourcegen:
>>> BUILD FAILED
>>> java.lang.NullPointerException
>>>        at
>>> org.apache.fop.tools.EventProducerCollector.createMethodModel(EventProducerCollector.java:138)
>>>
>
> Seems that QDox' JavaMethod.isReturns() may produce null in some cases,
> which results in Type.isVoid() yielding a NPE. Their API docs do not
> offer a lot of explanation, unfortunately....
>
> Do you have another version of QDox in the classpath? Does Eclipse use
> the exact same Java version/build?

No, the settings are exactly the same, nothing special. Could be the way
the classpath entries are ordered? On my system (Gentoo) there is a
global qdox library, but it's the same version as the one provided in
the lib directory (although not exactly the same binary, since Gentoo
builds all packages locally, from the sources).
--
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document requires Password

by John T :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi. Wondering if this issue with a password being required was ever addressed? I just downloaded the latest FOP code from the trunk and compiled and the same issue is occurring: a password is being required even though no password as been set:

userAgent.getRendererOptions().put("encryption-params", new PDFEncryptionParams(null, null, true, false, false, false));

John

Not sure if it is a possibility for you to download and build FOP  
Trunk. If you have Subversion and Ant available on your system, then  
it requires virtually no extra effort. Just check out with Subversion,  
navigate to FOP's root directory in a terminal window, and run 'ant  
package' to create the fop.jar.

see also: http://xmlgraphics.apache.org/fop/download.html#source


HTH!

Andreas

Re: PDF document requires Password

by Andreas Delmelle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 02 Jul 2009, at 22:16, John T wrote:

>
> Hi. Wondering if this issue with a password being required was ever
> addressed?

One issue was addressed that triggered this behavior in older PDF  
viewers. At that time, the user having raised the issue, confirmed  
that using FOP Trunk resolved it.

> I just downloaded the latest FOP code from the trunk and compiled
> and the same issue is occurring: a password is being required even  
> though no
> password as been set:
>
> userAgent.getRendererOptions().put("encryption-params", new
> PDFEncryptionParams(null, null, true, false, false, false));

Which PDF viewer did you try? Are you sure FOP's trunk version is the  
one that is actually used at runtime?
The above should work, although we normally recommend to provide at  
least the owner password (so you can still override the restrictions,  
if necessary).


Regards

Andreas

Andreas Delmelle
mailto:andreas.delmelle.AT.telenet.be
jabber: mandreas@...
skype: adlm0608

---


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...


Re: PDF document requires Password

by John T :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

H Andreas. I am quite certain I am using the trunk version at runtime. I've tried various versions of Adobe Acrobat reader on Windows from version 5 to version 9.

John

Andreas Delmelle-2 wrote:
One issue was addressed that triggered this behavior in older PDF  
viewers. At that time, the user having raised the issue, confirmed  
that using FOP Trunk resolved it.

Which PDF viewer did you try? Are you sure FOP's trunk version is the  
one that is actually used at runtime?
The above should work, although we normally recommend to provide at  
least the owner password (so you can still override the restrictions,  
if necessary).


Regards

Andreas

Re: PDF document requires Password

by John T :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John T wrote:
H Andreas. I am quite certain I am using the trunk version at runtime. I've tried various versions of Adobe Acrobat reader on Windows from version 5 to version 9.

John

Nevermind, its now working. Not sure how this happened, but my fop.conf file had these entries:

<encryption-params>
<user-password>testuserpass</user-password>
<owner-password>testownerpass</owner-password>
<noprint/>
<nocopy/>
<noedit/>
<noannotations/>
</encryption-params>

I didn't add them ...

John