[Date Index]
[Thread Index]
[Author Index]
Re: Assembling PDFs into a PDF document?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg121199] Re: Assembling PDFs into a PDF document?
*From*: JUN <noeckel at gmail.com>
*Date*: Sat, 3 Sep 2011 17:56:12 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*References*: <j3q0ql$6fn$1@smc.vnet.net>
On Sep 2, 12:32 am, AES <sieg... at stanford.edu> wrote:
> [I can set about learning how to do the following by myself, but if
> anyone has an off-the-cuff answer or pointers to the starting point,
> I'll be appreciative.]
>
> Given a large number of single-page PDF image files, all in a single
> folder (on a Mac), write a notebook that will build a single multipage
> document containing some or all of these files, in accordance with
> (and with page order determined by) a list of some or all of these
> image file names.
>
> For extra credit: Have each page in the final document bookmarked by
> the name of the corresponding file.
>
> Thanks for any assistance.
I think the only reason this may be worth doing in Mathematica is that
the sorting and selection of the input files perhaps requires some
nontrivial processing. Assuming you have already solved that problem,
here is a simple way to proceed.
Calling this a Mathematica solution is perhaps cheating, but here it
is anyway:
coalescePDF[inputFiles_?ListQ, outputFile_?StringQ] :=
If[FileExistsQ[outputFile],
Print[outputFile <>
" already exists and has not been overwritten"],
Run["/System/Library/Automator/Combine\\ PDF\\ \
Pages.action/Contents/Resources/join.py --output " <> outputFile <>
" " <> StringJoin[Riffle[inputFiles, " "]]]
]
The input filenames are passed to this function as strings in the list
inputFiles, and the desired output file name is the second argument.
So you would call it like this:
coalescePDF[{"picture1.pdf","picture2.pdf"}, "output.pdf"]
Just in case the line breaks are ambiguous when this gets posted, make
sure the string in the path name reads as one line containing
"Combine\\ PDF\\ Pages.action"
That's an Automator action that comes with OS X, so it's perhaps
better than using LaTeX or ghostscript etc., although I'm sure you
have those installed too.
Regards,
Jens
Prev by Date:
** Re: Mathematica collect function,**
Next by Date:
**Re: Assembling PDFs into a PDF document?**
Previous by thread:
**Re: Assembling PDFs into a PDF document?**
Next by thread:
**Re: Assembling PDFs into a PDF document?**
| |