还有人用`pdftk'和`make'一起合并PDF文件?

时间:2010-12-03 01:15:29

标签: makefile documentation-generation pdftk

今年,我想出了一种使用pdftk' and 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。

先谢谢

0 个答案:

没有答案