2

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

bjem
  • 175
  • 6
  • What are you asking? It doesn't look like you actually have a problem. – Matt Ball Dec 03 '10 at 01:29
  • There is no problem with this at the moment, but I am asking if (1) anybody else has done this and (2) whether they have had any problems themselves. Ya know, before this is used in a 'production environment'. – bjem Dec 03 '10 at 03:18

0 Answers0