Re: Assembling PDFs into a PDF document?
- To: mathgroup at smc.vnet.net
- Subject: [mg121279] Re: Assembling PDFs into a PDF document?
- From: Ulrich Arndt <ulrich.arndt at data2knowledge.de>
- Date: Wed, 7 Sep 2011 05:39:52 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201109020729.DAA06595@smc.vnet.net>
Hi,
this might work if the PDFs will always smaller than a page.
1. generate some sample PDF files - sin plots
dir = NotebookDirectory[];
t = 20;
d = Table[Plot[Sin[a x], {x, 1, 20}], {a, 1, t}];
Export[FileNameJoin[{dir,
"Sin[" <> ToString[NumberForm[#, 2, NumberPadding -> "0"]] <>
"t].pdf"}], d[[#]]] & /@ Range[t]
2. Get file name list
files = FileNames[dir <> "Sin*.pdf"];
3. Generate Notebook - (maybe bruce force but seems to work)
Flatten is used to get a final list of Cell objects.
It creates a title page and one section per file. Filename is used for the section name and at the end of each Section a page break is added..
l = Flatten[{{TextCell["My Title for this Doc", "Title"],
Cell["", "PageBreak",
PageBreakBelow ->
True]}, {TextCell[FileNameTake[files[[#]]], "Section"],
ExpressionCell[Import[files[[#]]][[1]], "Input"],
Cell["", "PageBreak", PageBreakBelow -> True]} & /@
Range@Length[files]}];
nb = CreateDocument[l, Visible -> False, NotebookFileName -> "test"]
4. Save Notebook as PDF
Export[dir <> "test.pdf", nb]
5. Clean up test files
DeleteFile[dir <> "test.nb"]
DeleteFile[files]
Maybe not 100% what you looking for but would avoid other tools.
Ulrich
--
www.data2knowledge.de
Am 02.09.2011 um 09:29 schrieb AES:
> [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.
>
- References:
- Assembling PDFs into a PDF document?
- From: AES <siegman@stanford.edu>
- Assembling PDFs into a PDF document?