将两个PDF页面合并为新页面,文本内容之间不留空格 [英] Merge two PDF pages into new one without blank spaces between text content

查看:357
本文介绍了将两个PDF页面合并为新页面,文本内容之间不留空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部

我想将两个PDF合并为一个PDF.同时,我想无缝地将这两个PDF结合在一起.

I want to merge two PDFs as one PDF. In the meantime I would like to join these two PDFs seamlessly.

例如,假设第一个PDF文件的最后一页有很多空白,合并后,我希望第二个PDF从第一个PDF的空白开始.

For example, say the last page of the first PDF file have quite a lot of empty spaces, after merging, I would hope that the second PDF will start from the blank spaces of the first PDF.

我们有什么工具可以支持吗?

Do we have any tool supporting that?

推荐答案

这并不是一件容易的事:

this is a not so hard task to do:

假设我们有两个像这样的pdf

assuming we have two pdf looking like these

  • 1.pdf: http://ge.tt/1tl71Gf/v/0
  • 2.pdf: http://ge.tt/1tl71Gf/v/1

我们希望将这两个pdf页面合并到新的 单一个 页面中,这样,以免浪费太多纸张并节省开支(请参见下图) : http://ge.tt/1tl71Gf/v/3 ),而不是拥有很多两页文字之间的空白(请参见以下右图: http://ge.tt/1tl71Gf/v/5 ):

we want to join these two pdf pages into new single one page loking like this, in order to waste not too much paper and economize (see the following left image: http://ge.tt/1tl71Gf/v/3), instead to having a lot of white space between the text of two pages (see the following right image: http://ge.tt/1tl71Gf/v/5):

然后,我们开始粗略估计文本后第一张pdf页面中的可用空间,以插入第二页及其文本.在我们的案例中,我们有一个A4文档,其后缀大小为: 595x841

we then start roughly estimating the space left free, in first pdf page, after text, to insert the second page3 with its text. In our case, we have an A4 document, whose sizes, in postscript point, are: 595x841

在两个pdf页面中,我们假设文本或多或少地以相同的高度开始,或者换句话说,以距上边距相同的距离开始,因此,如果要施加 second pdf页面及其文本位于第一 pdf页面上,没有覆盖第一页的文本,但是将其放置在此之后,我们需要方便地下移该文本的内容第二 pdf页面

in both two pdf pages, we assume that the the text starts more or less at same height, or in other words, at same distance from upper margin, so, if we want impose the second pdf page, with its text, on first pdf page, without cover the text of first page, but placing it after this, we need to conveniently move down the text content of second pdf page

在我们的示例案例中,我借助于 pdftk sed 将第二个pdf页面的文本内容向下移动了200点 (添加下移到原始高度的值(在本例中为841)以保留页面的几何形状,因此841变为1041,而页面的高度保持不变)

in our sample case I moved down the text content of second pdf page with the help of pdftk and sed, by 200 points (we add the value of down moving to the original height - 841 in our case - to preserve the geometry of page, so 841 becomes 1041, while the height of page remains the same)

sed 's/MediaBox \[0 0 595 841]/MediaBox \[0 200 595 1041 ]/g'<2.pdf>2bis.pdf

结果是这样(左上角的图像),而最初第二个pdf页面的文本内容开始时是右上角的图像:

and the result was this (image in left corner), while originally the text content of second pdf page started as in image in right corner:

现在,完成此操作之后;我们需要在第一个pdf页面上过度添加第二个pdf页面

now, after done this; we need to over impose the second pdf page on the first pdf page

这可以再次通过pdftk完成,将第二个pdf页面及其文本向下放置在背景中

this can be done, once again, with pdftk, placing the second pdf page with its text moved down, in backround

pdftk 1.pdf background 2bis.pdf output seamless_imposed.pdf

,结果如下: http://ge.tt/1tl71Gf/v/3

这篇关于将两个PDF页面合并为新页面,文本内容之间不留空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆