Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4801

Re: Assembling PDFs into a PDF document?

From Ulrich Arndt <ulrich.arndt@data2knowledge.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Assembling PDFs into a PDF document?
Date 2011-09-07 09:43 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j47ec9$l3d$1@smc.vnet.net> (permalink)
References <201109020729.DAA06595@smc.vnet.net>

Show all headers | View raw


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.
>


Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Assembling PDFs into a PDF document? Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2011-09-07 09:43 +0000

csiph-web