Message Boards Message Boards

0
|
4037 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Automatically export a notebook as multiple PDF files?

Posted 7 years ago

I have a notebook that keeps track of a series of notes, with each note being its own group of cells (the first cell also includes a "page break before"). If I save this notebook as a PDF file, I get a single PDF file with each note naturally starting on a new page.

What I would like to do is have Mathematica automatically export each note (group of cells) as a separate PDF file.

Is there a way to do this?

Thanks,

Andrew.

POSTED BY: Andrew
3 Replies

Andrew,

Although I have never used it, look at Authortools. See documentation here also see more details for programmatically exporting (and also use of a palette) here. You also can modify your code to Select cells and groups rather than deleting them using SelectionMove see here. I hope this helps.

Can you create the PDF and use Acrobat to split the pages? It has some capabilities for doing scripting.(I know -- it is not as elegant as doing it in Mathematica!).

This sounds like an interesting problem. Please post how you eventually figure out how to do it..

POSTED BY: Neil Singer
Posted 7 years ago

Thank you Neil. I will definitely check out the Authortools when I get the chance this weekend!

POSTED BY: Andrew
Posted 7 years ago

While it is not elegant, I did come up with a way to do it using CellTags (CellStyle would work too, I think). The only problem is that this approach requires deleting input cells and formatting the new notebooks to retain the formatting of the original notebook. I would still really like a solution that can create the PDFs from within the original notebook.

noteCells = Drop[Split[Cells[], CurrentValue[#2, CellTags] =!= "NewNote" &], -1];
pdf[c0_, n0_] :=
 Module[{c = c0, n = n0, nb},
  nb = CreateDocument[];
  NotebookWrite[nb, NotebookRead[c]];
  NotebookDelete[Cells[nb, CellStyle -> {"Input"}]];
  Export[FileNameJoin[{NotebookDirectory[], "test-notes-" <> ToString[n] <> ".pdf"}], nb];
  NotebookClose[nb];
  ]
MapIndexed[pdf[#1, First[#2]] &, noteCells];
POSTED BY: Andrew
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract