2
$\begingroup$

Is there any way to print out to pdf file, in sequence, all cells independently? I have literally hundreds of cells that need to be printed in that way. Selecting each cell and "Print Selections" takes me ages before I finish.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

A simple suggestion, assuming you want each cell in a separate file:

cellCounter = 1;
Map[
 Export[
   StringJoin["cell-", ToString[cellCounter++], ".pdf"],
   NotebookRead[#]] &, 
 Cells[]];

and the resulting file corresponding to this cell:

cell export

$\endgroup$
4
  • $\begingroup$ Awesome, thank you very much. It's possible to print out cells "In" and "Out" together (including labels). Now, each of them is printed to separated file. $\endgroup$
    – Thomas
    Jul 14, 2013 at 12:56
  • $\begingroup$ @thomas perhaps add these requirements to your question? I'm not much of a notebook programmer... $\endgroup$
    – cormullion
    Jul 14, 2013 at 13:23
  • $\begingroup$ @thomas Consider Split[Cells[], MemberQ[Cells[CellStyle -> {"Input"}], #1] && MemberQ[Cells[CellStyle -> {"Output"}], #2] &] and "CellLabelsToTags" $\endgroup$
    – Michael E2
    Jul 14, 2013 at 19:46
  • $\begingroup$ @cormullion: Ised the above code and get the pdf files but I cannot find the PDFs to print. Where are they stored? $\endgroup$ Sep 8, 2020 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.