带有印记文件位置控制的印记 PDF 文件
有谁知道如何将 PDF 文件标记为 PDF 文件以及定位 PDF 文件标记的控件吗?
我有一个文件 orinal.pdf
和 logo.pdf
。我想将 logo.pdf
文件标记为文件 original.pdf
左上角的文件 original.pdf
。如何使用Ghostscript或pdftk来完成它?
Does anyone know about stamping PDF file to PDF file and also controls for positioning PDF file stamp?
I have a file orginal.pdf
and logo.pdf
. I want to stamp logo.pdf
file to file orginal.pdf
at the top left of file original.pdf
. How can it be done with Ghostscript or pdftk?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用 Ghostscript plus pdftk 来完成,但它至少需要 2 个不同的步骤。
AFAIK,您无法直接控制
pdftk
的图章位置。默认情况下,它将图章放在页面的中心,同时执行“缩放以适合”操作。因此,您必须先修复印章,以便首先将其放置在空白页面上,就在您想要的位置。您可以在 Ghostscript 的帮助下第一步实现这一点。然后,在第二步中,使用 pdftk 合并两个文件。
让我们举个例子。
首先:创建“stamp-small.pdf”。 (你已经有你的了;我需要一个来演示原理。)
这个例子适用于 Linux 或 Mac OS X。在 Windows 上,你可以像这样修改它:(
你也可以将其全部放在一行中,但然后跳过该行- 相应操作系统的连续标记。)第一个命令将一系列简单的 PostScript 语句传递给 Ghostscript 的命令行,并告诉它创建一个尺寸为 320x50 pts 的小 PDF 页面。这应该模拟您寻求放置的“小”邮票。
第二:创建一个全页(在我的例子中是 A4 大小)PDF 文件,可以在第三步中将其应用为真正的图章:
在 Windows 上:
了几件事:
实际上,我原来的小尺寸邮票串现在位于 A4 页面的右上角。
第三:现在您可以使用 pdftk 将这个新的“标记”应用到您的原始 PDF 文件:
或者,标记多页原始 PDF 的所有页面:
这个示例应该让您对以下内容有足够的了解:如何为您自己的
logo.pdf
开发类似的程序,就像我为我的stamp-small.pdf
所做的那样。 (我是在右上角做的,你想在左上角做你的。)It can be done with Ghostscript plus pdftk, but it requires at least 2 different steps.
AFAIK, you cannot directly control
pdftk
's stamp placement. By default it puts the stamp on the center of the page, and at the same time does a 'scale-to-fit' operation.So, you have to fix your stamp first so it is placed on an empty page first, right at the position you want it. This you can achieve with the help of Ghostscript in a first step. Then, in a second step, use pdftk to merge the two files.
Let's use an example.
First: Create a 'stamp-small.pdf'. (You have yours already; I need one to demonstrate the principle.)
This example was for Linux or Mac OS X. On Windows you would modify it like this:
(You could also put it all in one line, but then skip the line-continuation marks for the respective OS.) This first command hands a series of simple PostScript statements to Ghostscript's commandline and tells it to create a small PDF page with a dimension of 320x50 pts. This should simulate your 'small' stamp which you seek placement for.
Second: Create a full-page (in my case, an A4-sized) PDF file which can be applied in the third step as the real stamp:
On Windows:
This command achieved several things:
Effectively, my original small-sized stamp string is now in the top right corner of an A4 page.
Third: Now you can apply this new 'stamp' to your original PDF file using pdftk:
or, to stamp all pages of a multi-page original PDF:
This example should give you enough of an idea about how to develop a similar procedure for your own
logo.pdf
as I did for mystamp-small.pdf
. (I did it for the top right corner, you want yours for the top left corner.)