MathGroup Archive 2011

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

Search the Archive

Re: Assembling PDFs into a PDF document?

Hi AES, 

This solution cheats because it uses latex to do the  real job. However, it does use mathematica to assemble the latex code. To use it:

1. place your pdf's in a subdirectory of the directory that contains the notebook (avoid file names that confuse latex)
2. supply the name of the subdirectory in the notebook in the variable pdfsubdirectory (in this example the directory is called "pdf_files")
3. Execute the notebook.

This creates a latex file in the current directory that uses the package pdfpages. Typeset it and you will get the assembled pdf. I suppose one should be able to send the typesetting command directly from Mathematica to the shell to fully automate the process, but this job is for another volunteer :-)


(*specify name of subdirectory that contains the pdf files*)

pdfsubdirectory = "pdf_files";
thisdirectory = SetDirectory@NotebookDirectory[];

(*read in list of pdfs*)

mypdffiles = FileNames["*.pdf", pdfsubdirectory];
numberoffiles = Length[mypdffiles];

(*build latex code*)

latexcode = 
  StringJoin @@ 
      ToString[mypdffiles[[i]]], "}\n"], {i, 1, 
      numberoffiles}], {"\\end{document}"}];
Export["assemblepdf.tex", latexcode, "Text"]

  • Prev by Date: Resizing graphics
  • Next by Date: Re: Quit versus Clear["Global`*"]
  • Previous by thread: Re: Assembling PDFs into a PDF document?
  • Next by thread: Re: Assembling PDFs into a PDF document?