markdown 在linux上拆分和合并pdf文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 在linux上拆分和合并pdf文件相关的知识,希望对你有一定的参考价值。

# How to merge or split pdf files using convert
[source: https://linuxcommando.blogspot.com/2015/03/how-to-merge-or-split-pdf-files-using.html](https://linuxcommando.blogspot.com/2015/03/how-to-merge-or-split-pdf-files-using.html)

_convert_ is a member of the _ImageMagick_ software suite for image manipulation. Two of my earlier posts dealt with using convert to slice and resize an image. It is a lesser-known fact that convert also works with pdf files.

First, you need to install convert which is packaged in the _ImageMagick_ suite.

```[bash]
$ sudo apt-get install imagemagick
```

### Merge full pdf files
Merging 2 pdf files (file1 and file2) into a new file (output) is as simple as executing:

    $ convert file1.pdf file2.pdf output.pdf

### Merge partial pdf files
You can merge a subset of pages instead of the entire input files. To accomplish that, use the angle brackets to specify the target subset of pages. For example, to merge page 1 of file1 with pages 1, 2 and 4 of file2, run the following command:

    $ convert file1.pdf[0] file2.pdf[0-1,3] output.pdf

Note that page numbers are zero-based. Therefore, [0] is page 1, and [0-1] are the pages ranging from page 1 to page 2.

### Split pdf files
Finally, the following example splits up input into 2 files: first2output and next2output. The former output file contains pages 1 and 2 from the original file; the latter, pages 3 and 4.

    $ convert input.pdf[0-1] first2output.pdf
    $ convert input.pdf[2-3] next2output.pdf

以上是关于markdown 在linux上拆分和合并pdf文件的主要内容,如果未能解决你的问题,请参考以下文章

Java 合并拆分PDF文档

Java 合并拆分PDF文档

JAVA实现PDF合并拆分代码工具类

JAVA实现PDF合并拆分代码工具类

[收藏]总有一天会用上的PDF合并及PDF拆分方法

# Itext Pdf 合并拆分