linux中打开pdf文件_如何在Linux中从PDF文件删除密码

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

linux中打开pdf文件

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

You’ve protected a PDF file containing sensitive information with a long, secure password so only the intended party can open it. However, you don’t want to enter that password every time you access the document, so you want to remove the password from your copy.

您已使用安全的长密码保护了包含敏感信息的PDF文件,因此只有预定的参与者才能打开它。 但是,您不想每次访问文档时都输入该密码,因此想从副本中删除该密码。

We will show you four ways in Linux to remove a password from a PDF file when you know the password.

当您知道密码时,我们将向您展示Linux中从PDF文件删除密码的四种方法。

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

注意:当我们说要在本文中键入某些内容并且文本周围有引号时,请不要键入引号,除非我们另外指定。

使用PDF工具包(pdftk) (Using the PDF Toolkit (pdftk))

The PDF Toolkit is a handy command line tool for manipulating PDF files. To install pdftk, press Ctrl + Alt + T to open a Terminal window. Type the following command at the prompt and press Enter.

PDF Toolkit是用于处理PDF文件的便捷命令行工具。 要安装pdftk,请按Ctrl + Alt + T打开“终端”窗口。 在提示符下键入以下命令,然后按Enter。

sudo apt-get install pdftk

须藤apt-get install pdftk

Type the password for your user account when prompted and press Enter.

出现提示时,输入用户帐户的密码,然后按Enter。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

The installation process begins with an analysis of your system and lists how many packages will be installed and how much space they will use. When asked if you want to continue, type a “y” and press Enter.

安装过程首先要对系统进行分析,并列出将安装多少个软件包以及它们将使用多少空间。 当询问您是否要继续时,键入“ y”,然后按Enter。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

When the installation is finished type the following command at the prompt, replacing the relevant parts as indicated below.

安装完成后,在提示符下键入以下命令,如下所示更换相关部件。

pdftk /home/lori/Documents/secured.pdf input_pw password output /home/lori/Documents/unsecured.pdf

pdftk /home/lori/Documents/secured.pdf input_pw密码输出/home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

该命令的细分如下:

pdftk Name of the command
/home/lori/Documents/secured.pdf Full path and filename of the password-protected PDF file. Replace this with the full path and filename for your password-protected PDF file.
input_pw password Prompt for entering the user password for the protected PDF file and the password used to open the file. Replace “password” with the password used to open your file.
output /home/lori/Documents/unsecured.pdf Prompt for the path and file name you want to use for the unprotected PDF file generated by pdftk followed by the full path and filename for the unprotected PDF file that will be generated. Replace the path shown here with the full path and filename you want to use for the unprotected PDF file generated by pdftk.
pdf文件 命令名称
/home/lori/Documents/secured.pdf 受密码保护的PDF文件的完整路径和文件名。 将其替换为受密码保护的PDF文件的完整路径和文件名。
input_pw密码 提示输入受保护的PDF文件的用户密码和用于打开文件的密码。 将“ password”替换为用于打开文件的密码。
输出/home/lori/Documents/unsecured.pdf 提示您要用于pdftk生成的不受保护的PDF文件的路径和文件名,然后是将要生成的不受保护的PDF文件的完整路径和文件名。 将此处显示的路径替换为要用于pdftk生成的不受保护的PDF文件的完整路径和文件名。

Press Enter to execute the command.

按Enter执行命令。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

The unprotected PDF file is generated and saved to the location you specified in the command.

生成不受保护的PDF文件,并将其保存到命令中指定的位置。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

使用QPDF (Using QPDF)

QPDF is a command-line program for Linux that converts from one PDF file to another equivalent PDF file while preserving the content of the file. The tool allows you to encrypt and decrypt, web-optimize, and split and merge PDF files.

QPDF是Linux的命令行程序,可以在保留文件内容的同时从一个PDF文件转换为另一个等效的PDF文件。 该工具使您可以加密和解密,网络优化以及拆分和合并PDF文件。

If you’re using the latest version of Ubuntu (14.04 as of the writing of this article), QPDF is most likely installed. If it’s not installed, press Ctrl + Alt + T to open a Terminal window and type the following command at the prompt.

如果您使用的是最新版本的Ubuntu(在撰写本文时为14.04),则很有可能已安装QPDF。 如果尚未安装,请按Ctrl + Alt + T打开“终端”窗口,并在提示符下键入以下命令。

sudo apt-get install qpdf

须藤apt-get install qpdf

Type your account password when prompted and press Enter.

在出现提示时输入您的帐户密码,然后按Enter。

Once QPDF is installed, type the following command at the prompt and press Enter.

安装QPDF后,在提示符下键入以下命令,然后按Enter。

qpdf –password=password –decrypt /home/lori/Documents/secured.pdf /home/lori/Documents/unsecured.pdf

qpdf –password = password –decrypt /home/lori/Documents/secured.pdf /home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

该命令的细分如下:

qpdf Name of the command
--password=password Prompt for the password to open the protected PDF file. Enter the password for your file after the equals sign.
NOTE: There are two dashes before “password” on the left side of the equals sign.
--decrypt /home/lori/Documents/secured.pdf Prompt for the full path and filename of the PDF file from which you want to remove the password. Replace the full path and filename with one for your file.
/home/lori/Documents/unsecured.pdf Full path and filename for the unprotected PDF file that will be generated. Replace this with the full path and filename you want to use for the unprotected PDF file generated by QPDF.
qpdf 命令名称
--密码=密码 提示输入密码以打开受保护的PDF文件。 在等号后输入文件的密码。
注意:等号左侧的“密码”前有两个破折号。
--解密/home/lori/Documents/secured.pdf 提示您要从中删除密码的PDF文件的完整路径和文件名。 将完整路径和文件名替换为一个文件。
/home/lori/Documents/unsecured.pdf 将生成的不受保护的PDF文件的完整路径和文件名。 将其替换为要用于QPDF生成的不受保护的PDF文件的完整路径和文件名。
linux中打开pdf文件_如何在Linux中从PDF文件删除密码

使用xpdf-utils (Using xpdf-utils)

Xpdf-utils is a package of PDF utilities that includes a PDF to PostScript converter (pdftops), a PDF document information extractor (pdfinfo), a PDF image extractor (pdfimages), a PDF to text converter (pdftotext), and a PDF font analyzer (pdffonts). For more information about each tool, type the command (in parentheses for each tool listed) followed by “–help” (two dashes before help).

Xpdf-utils是PDF实用程序的软件包,其中包括PDF到PostScript转换器(pdftops),PDF文档信息提取器(pdfinfo),PDF图像提取器(pdfimages),PDF到文本转换器(pdftotext)和PDF字体分析器(pdffonts)。 有关每个工具的更多信息,请键入命令(在列出的每个工具的括号中),然后键入“ -help”(帮助前两个破折号)。

To remove a password from a PDF file, we will use the PDF to PostScript (pdftops) tool and the Ghostscript PostScript-to-PDF Converter to convert the postscript file back to an unprotected PDF file.

要从PDF文件中删除密码,我们将使用PDF to PostScript(pdftops)工具和Ghostscript PostScript-to-PDF Converter将Postscript文件转换回不受保护的PDF文件。

The xpdf-utils package may already be installed if you’re using the latest version of Ubuntu. If not, type the following command at the prompt and press Enter to install the package.

如果您使用的是最新版本的Ubuntu,则可能已经安装了xpdf-utils软件包。 如果不是,请在提示符下键入以下命令,然后按Enter键安装软件包。

sudo apt-get install xpdf-utils

须藤apt-get install xpdf-utils

Type your account password when prompted and press Enter.

在出现提示时输入您的帐户密码,然后按Enter。

Once xpdf-utils is installed, you’re ready to convert your password-protected PDF file to a postscript file. Type the following command at the prompt and press Enter.

一旦安装了xpdf-utils,就可以将受密码保护的PDF文件转换为Postscript文件了。 在提示符下键入以下命令,然后按Enter。

pdftops -upw password /home/lori/Documents/secured.pdf /home/lori/Documents/unsecured.pdf

pdftops -upw密码/home/lori/Documents/secured.pdf /home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

该命令的细分如下:

pdftops Name of the command
-upw password Prompt for the user password to open the protected PDF file. Replace “password” with the password that opens your protected PDF file.
NOTE: There is one dash before “upw”.
/home/lori/Documents/secured.pdf Full path and filename of the password-protected PDF file. Replace this with the full path and filename for your password-protected PDF file.
/home/lori/Documents/unsecured.pdf Full path and filename for the unprotected PDF file that will be generated. Replace this with the full path and filename you want to use for the unprotected PDF file generated by pdftops.
pdftops 命令名称
-upw密码 提示输入用户密码以打开受保护的PDF文件。 将“ password”替换为打开受保护的PDF文件的密码。
注意:“ upw”之前有一个破折号。
/home/lori/Documents/secured.pdf 受密码保护的PDF文件的完整路径和文件名。 将其替换为受密码保护的PDF文件的完整路径和文件名。
/home/lori/Documents/unsecured.pdf 将生成的不受保护的PDF文件的完整路径和文件名。 将其替换为要用于pdftops生成的不受保护的PDF文件的完整路径和文件名。
linux中打开pdf文件_如何在Linux中从PDF文件删除密码

The postscript file is generated and placed in the folder you specified in the command.

生成后记文件,并将其放置在命令中指定的文件夹中。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

Before converting the postscript file back to an unprotected PDF file, you must install the Ghostscript Postscript-to-PDF Converter (ps2pdf). To do this, type the following command at the prompt and press Enter.

将Postscript文件转换回不受保护的PDF文件之前,必须安装Ghostscript Postscript到PDF转换器(ps2pdf)。 为此,请在提示符下键入以下命令,然后按Enter。

sudo apt-get install context

sudo apt-get安装上下文

Type your account password at the prompt and press Enter.

在提示符下输入您的帐户密码,然后按Enter。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

The installation process begins with an analysis of your system and lists how many packages will be installed and how much space they will use. When asked if you want to continue, type a “y” and press Enter.

安装过程首先要对系统进行分析,并列出将安装多少个软件包以及它们将使用多少空间。 当询问您是否要继续时,键入“ y”,然后按Enter。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

Once ps2pdf is installed, type the following command at the prompt and press Enter.

安装ps2pdf后,在提示符下键入以下命令,然后按Enter。

ps2pdf /home/lori/Documents/unsecured.ps /home/lori/Documents/unsecured.pdf

ps2pdf /home/lori/Documents/unsecured.ps /home/lori/Documents/unsecured.pdf

The breakdown of the command is as follows:

该命令的细分如下:

ps2pdf Name of the command
/home/lori/Documents/secured.ps Full path and filename of the postscript file. Replace this with the full path and filename for your postscript file.
/home/lori/Documents/unsecured.pdf Full path and filename for the unprotected PDF file that will be generated. Replace this with the full path and filename you want to use for the unprotected PDF file generated from the postscript file by ps2pdf.
ps2pdf 命令名称
/home/lori/Documents/secured.ps 后记文件的完整路径和文件名。 将其替换为您的脚本文件的完整路径和文件名。
/home/lori/Documents/unsecured.pdf 将生成的不受保护的PDF文件的完整路径和文件名。 将其替换为要用于由ps2pdf从后记文件生成的不受保护的PDF文件的完整路径和文件名。
linux中打开pdf文件_如何在Linux中从PDF文件删除密码

A new, unprotected PDF file is generated and placed in the folder you specified in the command.

将生成一个新的不受保护的PDF文件,并将其放置在命令中指定的文件夹中。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

使用Evince (Using Evince)

Evince is the default PDF file viewer that comes with Ubuntu. You can use it to remove a password from a PDF file as long as you know the password. It’s a graphical tool, but we will run it from the command line. To run Evince, type the following command at the prompt and press Enter.

Evince是Ubuntu随附的默认PDF文件查看器。 只要知道密码,就可以使用它从PDF文件中删除密码。 这是一个图形工具,但是我们将从命令行运行它。 要运行Evince,请在提示符下键入以下命令,然后按Enter。

evince /home/lori/Documents/secured.pdf

证据/home/lori/Documents/secured.pdf

Replace the full path and filename for your PDF file.

替换PDF文件的完整路径和文件名。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

NOTE: You may see the following error message, but the file will open anyway.

注意:您可能会看到以下错误消息,但是该文件仍然会打开。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

Evince displays a dialog box asking for the user password to open the PDF file. Enter the password in the edit box and select how long you want Evince to remember the password. Click “Unlock Document”.

Evince显示一个对话框,要求您输入用户密码以打开PDF文件。 在编辑框中输入密码,然后选择您希望Evince记住密码多长时间。 点击“解锁文件”。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

When the PDF file opens, select “Print” from the “File” menu.

当PDF文件打开时,从“文件”菜单中选择“打印”。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

On the “Print” dialog box, select “Print to File”. If you want to change the filename or the location where it’s saved, click the button next to “File” showing the path and filename.

在“打印”对话框中,选择“打印到文件”。 如果要更改文件名或文件的保存位置,请单击“文件”旁边的按钮,显示路径和文件名。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

On the “Select a filename” dialog box, navigate to the location where you want to save the unprotected PDF file and enter a name for the file in the Name field. Click “Select”.

在“选择文件名”对话框上,导航到要保存不受保护的PDF文件的位置,然后在“名称”字段中输入文件的名称。 点击“选择”。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

The new path and filename displays on the “File” button. Accept the default settings for the other options and click “Print”.

新的路径和文件名显示在“文件”按钮上。 接受其他选项的默认设置,然后单击“打印”。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

The unprotected PDF file is saved to the location you chose.

不受保护的PDF文件将保存到您选择的位置。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

Double-click on the file to open it again in Evince. Notice that you are not asked for the password.

双击该文件以再次在Evince中将其打开。 请注意,系统不会要求您输入密码。

linux中打开pdf文件_如何在Linux中从PDF文件删除密码

Remember, to remove a password from a PDF file using these tools you must know the password.

请记住,要使用这些工具从PDF文件中删除密码,您必须知道密码。

翻译自: https://www.howtogeek.com/197195/how-to-remove-a-password-from-a-pdf-file-in-linux/

linux中打开pdf文件