translating

This commit is contained in:
geekpi 2023-04-17 08:45:39 +08:00
parent 3756ed621d
commit fbbfa7ea94
2 changed files with 180 additions and 182 deletions

View File

@ -1,182 +0,0 @@
[#]: subject: "How to Merge PDF Files in Linux"
[#]: via: "https://itsfoss.com/merge-pdf-linux/"
[#]: author: "Sagar Sharma https://itsfoss.com/author/sagar/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How to Merge PDF Files in Linux
======
Got several PDFs on the same subject and now you want to combine them into a single PDF?
Or perhaps you need to upload a single file consisting of different files? Many government and academic portals require that.
As a Linux user, if you are in a situation where you need to merge PDFs, this tutorial will help you out.
In this tutorial, Ill share three methods of combining multiple PDF files:
- Using PDF Tricks GUI tool
- Using LibreOffice (allows you to select pages as well)
- Using the ImageMagick command line tool (Can a Linux tutorial be completed without the terminal method?)
You can read them all and pick the one that works best for you.
### Method 1: Use PDF Tricks GUI tool to merge PDF in Linux
After experimenting with several GUI tools, I found that the PDF Tricks was straightforward to use and easy to navigate.
Furthermore, it includes additional functionality beyond only merging PDF files, including:
- Compress PDFs.
- Split PDFs.
- Compress PDFs (into JPG, PNG, and text formats).
It is available as a [Flatpak][1]. Please [ensure that your Linux system has Flatpak support enabled][2].
I am sharing the steps for enabling Flatpak on Ubuntu:
```
sudo apt install flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
```
Now, use the below command to install PDF Tricks in your system:
```
flatpak install flathub com.github.muriloventuroso.pdftricks
```
Once you are done with the installation, open the PDF Tricks application from the system menu.
On the first run, you will get you a list of actions you can perform with this tool. To merge PDF files, go with the third option, obviously.
![merge pdf files using in ubuntu][3]
In the next step, click on **Add file** and select the files you want to merge:
![choose files to merge][4]
Once you select files, click on the **Merge** button:
![click on merge button][5]
And it will open the default file manager of your system. Here you can select where you want to save the merged file and what it should be named:
![locate and name the merged pdf file][6]
And thats it. The combined pdf has been saved.
And if you are looking for a tool, we have a list of the [best PDF readers that you can use to read and edit PDF files.][7]
**Related read**: List of [PDF editors available for Linux][7].
### Method 2: Merge PDF Files using LibreOffice
The awesome LibreOffice is capable of handling many PDF related tasks. You can even [edit PDF files with LibreOffice Draw tool][8] for adding a digital signature, adding text, and much more.
The good thing is that you dont need to install another application. LibreOffice is already installed on most distributions, if not all.
Open the file manager and select the PDF files that you want to merge.
**Right-click on selected files > Open With Other Application > LibreOffice Draw from there**, and it will open selected PDF files.
And it will open every PDF file you selected in a separate LibreOffice Draw instance:
![open pdf file in libreoffice][9]
Now, you have to **select individual pages or entire PDF file** (using Ctrl + A) from the left preview bar and drop it to the preview bar of the file that you want to combine with:
Once you are done with drag and drop, click on the 5th option from the top left, labeled as **Export Directly as PDF**:
![export directly as pdf in libreoffice][10]
And it will open a file manager from where you can locate and name the file:
![save merged file from libreoffice][11]
And thats it!
### Bonus Tip: Merge PDFs in the command line [For advanced users]
What kind of Linux tutorial would it be if I didnt include the command line method? To merge PDF files in the command line, you can use ImageMagick.
ImageMagick is actually an image-related tool. PDF files are essentially images and this is why ImageMagick can work with them.
You probably dont even need to [install ImageMagick][12] as it is already installed in most distros by default.
For example, I will be adding 3 PDF files named pdf-1.pdf, pdf-2.pdf, and pdf-3.pdf and will name the final merged PDF file output as MergedFile.pdf (how clever):
```
convert pdf-1.pdf pdf-2.pdf pdf-3.pdf MergedFile.pdf
```
#### Troubleshooting no images defined
If you see a policy error like this:
![convert im6.q16: attempt to perform an operation not allowed by the security policy `pdf' @ error constitute.c iscoderauthorized 421.][13]
The problem is quite easy to solve. You just have to make minor changes in the ImageMagick policy file.
Open the policy file for editing:
```
sudo nano /etc/ImageMagick-6/policy.xml
```
And look for the following line:
```
<policy domain="coder" rights="none" pattern="PDF" />
```
Now, you have to change the `rights="none"` to `rights=read|write`:
```
<policy domain="coder" rights="read|write" pattern="PDF" />
```
![change policy in imagemagick to merge pdf files][14]
Save the changes, and now you can easily merge files using ImageMagick:
![merge pdf files using imagemagick in linux terminal][15]
### Wrapping Up
Now you know several ways of combining PDF files in Linux. Chances are that the merged PDF file is big in size. If you have to upload the merged PDF file on a portal that has size restrictions, you can [compress the PDF file][16].
Let me know if you face any issues with above discussed methods.
--------------------------------------------------------------------------------
via: https://itsfoss.com/merge-pdf-linux/
作者:[Sagar Sharma][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/sagar/
[b]: https://github.com/lkxed
[1]: https://itsfoss.com/what-is-flatpak/
[2]: https://itsfoss.com/flatpak-guide/
[3]: https://itsfoss.com/wp-content/uploads/2022/11/merge-pdf-files-using-in-ubuntu-1.png
[4]: https://itsfoss.com/wp-content/uploads/2022/11/choose-files-to-merge.png
[5]: https://itsfoss.com/wp-content/uploads/2022/11/click-on-merge-button.png
[6]: https://itsfoss.com/wp-content/uploads/2022/11/locate-and-name-the-merged-pdf-file.png
[7]: https://itsfoss.com/pdf-editors-linux/
[8]: https://itsfoss.com/edit-pdf-files-ubuntu-linux/
[9]: https://itsfoss.com/wp-content/uploads/2022/11/open-pdf-file-in-libreoffice.png
[10]: https://itsfoss.com/wp-content/uploads/2022/11/export-directly-as-pdf-in-libreoffice.png
[11]: https://itsfoss.com/wp-content/uploads/2022/11/save-merged-file-from-libreoffice.png
[12]: https://itsfoss.com/install-imagemagick-ubuntu/
[13]: https://itsfoss.com/wp-content/uploads/2022/11/convert-im6.q16-attempt-to-perform-an-operation-not-allowed-by-the-security-policy-pdf-@-error-constitute.c-iscoderauthorized-421.0a.png
[14]: https://itsfoss.com/wp-content/uploads/2022/11/change-policy-in-imagemagick-to-merge-pdf-files.png
[15]: https://itsfoss.com/wp-content/uploads/2022/11/merge-pdf-files-using-imagemagick-in-linux-terminal.png
[16]: https://itsfoss.com/compress-pdf-linux/

View File

@ -0,0 +1,180 @@
[#]: subject: "How to Merge PDF Files in Linux"
[#]: via: "https://itsfoss.com/merge-pdf-linux/"
[#]: author: "Sagar Sharma https://itsfoss.com/author/sagar/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
如何在 Linux 中合并 PDF 文件
======
有多个关于同一主题的 PDF现在你想将它们合并成一个 PDF
或者你可能需要上传由不同文件组成的单个文件? 许多政府和学术门户网站都要求这样做。
作为 Linux 用户,如果你遇到需要合并 PDF 的情况,本教程将帮助你。
在本教程中,我将分享三种合并多个 PDF 文件的方法:
- 使用 PDF Tricks GUI 工具
- 使用 LibreOffice允许你选择页面
- 使用 ImageMagick 命令行工具Linux 教程会没有终端方法就结束么?)
你可以全部阅读并选择最适合你的。
### 方法 1使用 PDF Tricks GUI 工具在 Linux 中合并 PDF
在试用了多种 GUI 工具后,我发现 PDF Tricks 使用简单且易于导航。
此外,除了合并 PDF 文件之外,它还包括其他功能,包括:
- 压缩 PDF。
- 拆分 PDF。
- 将 PDF 转换为 JPG、PNG 和文本格式。
它以 [Flatpak][1] 的形式提供。请[确保你的 Linux 系统启用了 Flatpak 支持][2]。
我分享的是在 Ubuntu 上启用 Flatpak 的步骤:
```
sudo apt install flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
```
现在,使用以下命令在你的系统中安装 PDF Tricks
```
flatpak install flathub com.github.muriloventuroso.pdftricks
```
完成安装后,从系统菜单中打开 PDF Tricks 应用。
第一次运行时,你会得到一个可以使用此工具执行的操作列表。显然,要合并 PDF 文件,请使用第三个选项。
![merge pdf files using in ubuntu][3]
在下一步中,单击**添加文件**并选择要合并的文件:
![choose files to merge][4]
选择文件后,单击**合并**按钮:
![click on merge button][5]
它将打开系统的默认文件管理器。你可以在此处选择要保存合并文件的位置以及应命名的文件:
![locate and name the merged pdf file][6]
就是这样。合并后的 pdf 已保存。
如果你正在寻找一种工具,我们提供了一份[可用于阅读和编辑 PDF 文件的最佳 PDF 阅读器][7]列表。
### 方法 2使用 LibreOffice 合并 PDF 文件
很棒的 LibreOffice 能够处理许多与 PDF 相关的任务。你甚至可以[使用 LibreOffice Draw 工具编辑 PDF 文件][8]来添加数字签名、添加文本等。
好处是你不需要安装其他应用。LibreOffice 已经安装在大多数发行版上,如果不是全部的话。
打开文件管理器并选择要合并的 PDF 文件。
**右键单击选定的文件 > 使用其他应用打开 > LibreOffice Draw**,它将打开选定的 PDF 文件。
它将在单独的 LibreOffice Draw 实例中打开你选择的每个 PDF 文件:
![open pdf file in libreoffice][9]
现在,你必须从左侧预览栏**选择单个页面或整个 PDF 文件**(使用 Ctrl + A并将其拖放到要合并的文件的预览栏
拖放后,单击左上角的第 5 个选项,标题是**直接导出为 PDF**
![export directly as pdf in libreoffice][10]
将打开一个文件管理器,你可以从中定位并命名文件:
![save merged file from libreoffice][11]
这就完成了!
### 额外技巧:在命令行中合并 PDF (对于高级用户)
如果我不包括命令行方法,那将是什么样的 Linux 教程? 要在命令行中合并 PDF 文件,你可以使用 ImageMagick。
ImageMagick 其实是一个图像相关的工具。PDF 文件本质上是图像,这就是 ImageMagick 可以处理它们的原因。
你可能甚至不需要[安装 ImageMagick][12],因为它已经默认安装在大多数发行版中。
例如,我将添加 3 个名为 pdf-1.pdf、pdf-2.pdf 和 pdf-3.pdf 的 PDF 文件,并将最终合并的 PDF 文件输出命名为 MergedFile.pdf多么聪明
```
convert pdf-1.pdf pdf-2.pdf pdf-3.pdf MergedFile.pdf
```
#### no images defined 故障排除
如果你看到这样的策略错误:
![convert im6.q16: attempt to perform an operation not allowed by the security policy `pdf` @ error constitute.c iscoderauthorized 421.][13]
这个问题很容易解决。你只需在 ImageMagick 策略文件中进行少量更改。
打开策略文件进行编辑:
```
sudo nano /etc/ImageMagick-6/policy.xml
```
并查找以下行:
```
<policy domain="coder" rights="none" pattern="PDF" />
```
现在,你需要将 `rights="none"` 更改为 `rights=read|write`
```
<policy domain="coder" rights="read|write" pattern="PDF" />
```
![change policy in imagemagick to merge pdf files][14]
保存更改,现在你可以使用 ImageMagick 轻松合并文件:
![merge pdf files using imagemagick in linux terminal][15]
### 总结
现在你知道了在 Linux 中合并 PDF 文件的几种方法。合并后的 PDF 文件可能很大。如果你需要在有大小限制的门户上传合并的 PDF 文件,你可以[压缩 PDF 文件][16]。
如果你在使用上述方法时遇到任何问题,请告诉我。
--------------------------------------------------------------------------------
via: https://itsfoss.com/merge-pdf-linux/
作者:[Sagar Sharma][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/sagar/
[b]: https://github.com/lkxed
[1]: https://itsfoss.com/what-is-flatpak/
[2]: https://itsfoss.com/flatpak-guide/
[3]: https://itsfoss.com/wp-content/uploads/2022/11/merge-pdf-files-using-in-ubuntu-1.png
[4]: https://itsfoss.com/wp-content/uploads/2022/11/choose-files-to-merge.png
[5]: https://itsfoss.com/wp-content/uploads/2022/11/click-on-merge-button.png
[6]: https://itsfoss.com/wp-content/uploads/2022/11/locate-and-name-the-merged-pdf-file.png
[7]: https://itsfoss.com/pdf-editors-linux/
[8]: https://itsfoss.com/edit-pdf-files-ubuntu-linux/
[9]: https://itsfoss.com/wp-content/uploads/2022/11/open-pdf-file-in-libreoffice.png
[10]: https://itsfoss.com/wp-content/uploads/2022/11/export-directly-as-pdf-in-libreoffice.png
[11]: https://itsfoss.com/wp-content/uploads/2022/11/save-merged-file-from-libreoffice.png
[12]: https://itsfoss.com/install-imagemagick-ubuntu/
[13]: https://itsfoss.com/wp-content/uploads/2022/11/convert-im6.q16-attempt-to-perform-an-operation-not-allowed-by-the-security-policy-pdf-@-error-constitute.c-iscoderauthorized-421.0a.png
[14]: https://itsfoss.com/wp-content/uploads/2022/11/change-policy-in-imagemagick-to-merge-pdf-files.png
[15]: https://itsfoss.com/wp-content/uploads/2022/11/merge-pdf-files-using-imagemagick-in-linux-terminal.png
[16]: https://itsfoss.com/compress-pdf-linux/