找回密码
 注册
查看: 1105|回复: 4

[原创] 在Linux下加密PDF 文档

[复制链接]
发表于 2005-8-16 11:37:25 | 显示全部楼层 |阅读模式
终于找到在Linux下加密PDF文档的方法,共享出来给大家,如有不妥,请各位提出意见和建议。

先在sourceforge.net上下载Multivalent20040415.jar,这是个java程序,在使用这个程序以前先确定自己安装了java,找不到的同学我通过mail发给你。

下载以后可以直接运行,比如我要加密一个叫1.pdf的文档,使用如下命令:
[code:1]
java -classpath /root/Multivalent20040415.jar tool.pdf.Encrypt -owner 123456 -user 111111 -restrict pPcCmtfa 1.pdf
[/code:1]
生成的新文件叫1-y.pdf,奇怪的命名方式。

使用心得:一开始我只使用-user设置密码,发现做的所有限制都不起作用,在他们网站上问过以后才发现要使用限制的话必须使用-owner参数设置密码,这样在打开文件时如果不使用-owner指定的参数,那么所有的限制都会有效。这一点很重要。我不懂java,这个运行方式是从网站上看来的。

选项的说明(从网站上复制过来):
[code:1]
Options

    java tool.pdf.Encrypt [options] PDF-files-or-directories

    * -password password -- directly re-encrypt a PDF by supplying the existing owner password
    * -user password -- set user password. In the absence of a user password, the null password is used, which lets one set restrictions without requiring a password to view the document.
    * -owner password -- set owner password.
    * -restrict[ions] actions -- (see below)
    * -perm[missions] actions -- -restrict and -perm set the operations available on the encrypted document. If -perm is given, then all actions are restricted except those so permitted. If -restrict is given, then all actions are permitted except those so restricted. If neither option is given, all operations are permitted. Actions are expressed as one or more letters from the following list:
          o p - print high-quality
          o P - print
          o c - copy or otherwise extract text and graphics
          o C - copy or otherwise extract text even for disabled users
          o m - modify the contents, such as creating form fields and signatures
          o t - annotate
          o f - fill in forms
          o a - assemble the document (insert, rotate, delete pages, create bookmarks or thumbnail images)
          o or all as a synonym for pPcCmtfa
    * -compat[ible] -- rather than 128-bit encryption, use only 40-bit encryption in order to be compatible with older PDF viewers (Acrobat 5 and later support 128-bit encryption). This is not recommended because 40-bit keys are easily cracked.
    * -inplace -- write encrypted PDF over existing

In the absence of -inplace, the encrypted version of the PDF is named with -y appended to the original file name.
[/code:1]

我还想找windows下加密pdf文档的软件,没找到好用的,总是需要注册,不知道哪位同学有可以自由使用的?谢谢!
发表于 2005-8-16 14:15:46 | 显示全部楼层
我感觉上的理由,不一定正确,欢迎大家补充!
owner项是指的是文件的所有者,user项是指的文件的一般用户,所以只在设置了所有者后,才能对一般用户的操作作限制!
至于为什么分成两个人,我认为这可能是PDF文件本身的需要,这样文件的所有者就是OWNER就可以给任何用户USER一些对应的权限了。

另外在WIN下,可以使用Adobe Acrobat来修改PDF文件的权限,
至于可以自由使用的,你给的这个就是一个java的程序,相信在win下应该也有对应的版本!
回复

使用道具 举报

 楼主| 发表于 2005-8-16 14:27:12 | 显示全部楼层
java程序应该是与平台无关的,所以我想这个程序在win下也应该可以运行,不懂java,没法做实验。
Acrobat如何修改权限?我用的7.0不能修改权限,版本问题?
回复

使用道具 举报

发表于 2005-8-16 14:56:29 | 显示全部楼层
[quote:f9ae812f16="sailer"]java程序应该是与平台无关的,所以我想这个程序在win下也应该可以运行,不懂java,没法做实验。
Acrobat如何修改权限?我用的7.0不能修改权限,版本问题?[/quote]

你有它程序的java源码吗?

注意你的Adobe Acrobat必须是标准版本的,不是那个免费的Read版本的就可以修改了!
回复

使用道具 举报

 楼主| 发表于 2005-8-18 21:33:59 | 显示全部楼层
[quote:3e978ce322="superpig"][quote:3e978ce322="sailer"]java程序应该是与平台无关的,所以我想这个程序在win下也应该可以运行,不懂java,没法做实验。
Acrobat如何修改权限?我用的7.0不能修改权限,版本问题?[/quote]

你有它程序的java源码吗?

注意你的Adobe Acrobat必须是标准版本的,不是那个免费的Read版本的就可以修改了![/quote]

我下载的是.jar文件,不知道这个是不是源代码?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2025-2-6 16:42 , Processed in 0.021900 second(s), 16 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表