📜  linux convert pdf trennen - Shell-Bash (1)

📅  最后修改于: 2023-12-03 14:43:54.956000             🧑  作者: Mango

Linux Convert PDF Trennen - Shell-Bash

PDF is a popular format for documents, but sometimes we might need to extract certain pages or split the PDF into multiple documents. Linux command line provides a powerful tool called "pdftk" which allows us to do these tasks easily. In this tutorial, we will learn how to use "pdftk" to convert and split PDF files in Linux using the Shell-Bash.

Installing pdftk

Before we start using "pdftk", we need to install it on our Linux system. We can use the following command to install "pdftk" on Ubuntu and Debian-based systems:

sudo apt-get install pdftk

For other Linux distributions, we can download the package from the official website and install it manually.

Extracting Pages from PDF

To extract specific pages from a PDF file, we can use the following command:

pdftk input.pdf cat <pages> output output.pdf

In the above command, "input.pdf" is the name of the input PDF file, is a comma-separated list of the pages you want to extract, and "output.pdf" is the name of the output file. For example, to extract pages 1, 3, and 5, we can use the following command:

pdftk input.pdf cat 1,3,5 output output.pdf
Splitting PDF into Multiple Documents

To split a PDF file into multiple documents, we can use the following command:

pdftk input.pdf burst output output_%04d.pdf

In the above command, "input.pdf" is the name of the input PDF file, and "output_%04d.pdf" is the format of the output file. The "%04d" is a placeholder for the page number, and it ensures that the files are named in a sequential order. For example, if the input PDF file has 10 pages, this command will create 10 output files named output_0001.pdf, output_0002.pdf, and so on.

Conclusion

The "pdftk" command-line tool is a very useful tool for handling PDF files in Linux. In this tutorial, we learned how to extract specific pages from a PDF file and split a PDF file into multiple documents using "pdftk". With the knowledge gained from this tutorial, you should be able to work with PDF files efficiently in your Linux system.