Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Assembling PDFs into a PDF document?

  • To: mathgroup at
  • Subject: [mg121279] Re: Assembling PDFs into a PDF document?
  • From: Ulrich Arndt <ulrich.arndt at>
  • Date: Wed, 7 Sep 2011 05:39:52 -0400 (EDT)
  • Delivered-to:
  • References: <>


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}];
    "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]} & /@
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"]

Maybe not 100% what you looking for but would avoid other tools.



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.

  • Prev by Date: PlotMarkers Documentation inconsistency
  • Next by Date: Re: How to generate report with Mathematica script from command line (no front end)
  • Previous by thread: Assembling PDFs into a PDF document?
  • Next by thread: Re: Assembling PDFs into a PDF document?