其他人使用了“pdftk”;和“制作”一起将PDF文件合并在一起?

发布于 2024-10-05 08:41:38 字数 2927 浏览 11 评论 0原文

今年我想出了一种使用pdftk'和make'将PDF文件合并在一起的方法。这是 makefile 的最新且最完善的版本。请注意,这是针对特定文件的,但当我在工作中执行此操作时,一些名称和目录已更改。

我发现这很有效,但我的问题是其他人是否使用过这种方法,您对这种方法有任何问题吗?

这是一个 makefile 示例。

# Makefile to create Build Methods Report, merging all the input source files 
# into one big PDF.

INFILE := Reusable_Component_Library_-_Evaulation_of_Build_Methods.odt
OUTFILE := Report.pdf

# PDF Files to assemble.
HANDLES := A B C D E F G H I J
FILE_A := Reusable_Component_Library_-_Evaulation_of_Build_Methods.pdf
FILE_B := Makefile.recurse.pdf
FILE_C := Makefile.recurse_module.pdf
FILE_D := Makefile.nonrecurse.pdf
FILE_E := user.mak.pdf
FILE_F := Makefile.semirecurse.pdf
FILE_G := project.mk.pdf
FILE_H := targets.mk.pdf
FILE_I := module.mk.pdf
FILE_J := modcomp.mk.pdf

# Page Merge Ranges.
FILE_MERGE_RANGES := A1-13 B A14 C A15 D A16 E A17 F A18 G A19 H A20 I A21 J

# Computed file lists and file dependency lists.
FILES := $(foreach a,$(HANDLES),$(FILE_$(a)))
FILE_HANDLES := $(foreach a,$(HANDLES),$(a)=$(FILE_$(a)))


# PDF Assembler
PDFTK := pdftk

.PHONY: all
all: $(OUTFILE)

#File A
Reusable_Component_Library_-_Evaulation_of_Build_Methods.pdf: Reusable_Component_Library_-_Evaulation_of_Build_Methods.odt
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File B
Makefile.recurse.pdf: ~/workspace/ncu_procedural_approach/Makefile.recurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)


Makefile.recurse_module.pdf: ~/workspace/ncu_procedural_approach/application/ate/Makefile.recurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)

# File C
Makefile.nonrecurse.pdf: ~/workspace/ncu_procedural_approach/Makefile.nonrecurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File D
Makefile.semirecurse.pdf: ~/workspace/ncu_procedural_approach/Makefile.semirecurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File E
modcomp.mk.pdf: ~/workspace/ncu_procedural_approach/modcomp.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File F
project.mk.pdf: ~/workspace/ncu_procedural_approach/project.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File G
user.mak.pdf: ~/workspace/ncu_procedural_approach/user.mak
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File H
targets.mk.pdf: ~/workspace/ncu_procedural_approach/targets.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File I
module.mk.pdf: ~/workspace/ncu_procedural_approach/application/ate/module.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


$(OUTFILE): $(FILES) $(MAKEFILE_LIST)
    $(PDFTK) $(FILE_HANDLES) cat $(FILE_MERGE_RANGES) output $(OUTFILE)

##### END OF FILE #####

正如您所看到的,这份文档有大量的附录。 $( 错误字符串在那里,因为我没有使用命令行生成 PDF。

提前致谢

This year I came up with a means of using pdftk' andmake' to merge PDF files together. This is the latest and most refined iteration of the makefile. Note that this is for a specific file but some names and directories have been changed as I did this one at work.

I've found this works well, but my question is has anybody else used this, and have you had any problems with this kind of method?

Here is an example makefile.

# Makefile to create Build Methods Report, merging all the input source files 
# into one big PDF.

INFILE := Reusable_Component_Library_-_Evaulation_of_Build_Methods.odt
OUTFILE := Report.pdf

# PDF Files to assemble.
HANDLES := A B C D E F G H I J
FILE_A := Reusable_Component_Library_-_Evaulation_of_Build_Methods.pdf
FILE_B := Makefile.recurse.pdf
FILE_C := Makefile.recurse_module.pdf
FILE_D := Makefile.nonrecurse.pdf
FILE_E := user.mak.pdf
FILE_F := Makefile.semirecurse.pdf
FILE_G := project.mk.pdf
FILE_H := targets.mk.pdf
FILE_I := module.mk.pdf
FILE_J := modcomp.mk.pdf

# Page Merge Ranges.
FILE_MERGE_RANGES := A1-13 B A14 C A15 D A16 E A17 F A18 G A19 H A20 I A21 J

# Computed file lists and file dependency lists.
FILES := $(foreach a,$(HANDLES),$(FILE_$(a)))
FILE_HANDLES := $(foreach a,$(HANDLES),$(a)=$(FILE_$(a)))


# PDF Assembler
PDFTK := pdftk

.PHONY: all
all: $(OUTFILE)

#File A
Reusable_Component_Library_-_Evaulation_of_Build_Methods.pdf: Reusable_Component_Library_-_Evaulation_of_Build_Methods.odt
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File B
Makefile.recurse.pdf: ~/workspace/ncu_procedural_approach/Makefile.recurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)


Makefile.recurse_module.pdf: ~/workspace/ncu_procedural_approach/application/ate/Makefile.recurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)

# File C
Makefile.nonrecurse.pdf: ~/workspace/ncu_procedural_approach/Makefile.nonrecurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File D
Makefile.semirecurse.pdf: ~/workspace/ncu_procedural_approach/Makefile.semirecurse
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File E
modcomp.mk.pdf: ~/workspace/ncu_procedural_approach/modcomp.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File F
project.mk.pdf: ~/workspace/ncu_procedural_approach/project.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File G
user.mak.pdf: ~/workspace/ncu_procedural_approach/user.mak
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File H
targets.mk.pdf: ~/workspace/ncu_procedural_approach/targets.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


# File I
module.mk.pdf: ~/workspace/ncu_procedural_approach/application/ate/module.mk
    $(error File $@ does not exist or is older than prerequisite(s) $^)


$(OUTFILE): $(FILES) $(MAKEFILE_LIST)
    $(PDFTK) $(FILE_HANDLES) cat $(FILE_MERGE_RANGES) output $(OUTFILE)

##### END OF FILE #####

As you can see, this document had a large number of appendices. The $(error strings were out there because I was not using the command line to generate the PDFs.

Thanks in Advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文