Pensieve header: A program for exporting tagged cells, continues pensieve://2013-03/ and pensieve://2013-05/.

Testing

SetDirectory["C:\\drorbn\\AcademicPensieve\\2013-08"];
Print[Date[]];
Module[{graph}, 
graph=Plot[Sin[((theta^2)/2)], {theta, 0, 2π}];
Print[graph]
];
Print[Solve[a (x^2)+b y+c==0, x]];
CellExport["CellExportTestTag", ExportFormat -> ".pdf"];
CellExport["CellExportTestTag", ExportFormat -> ".png"]
(* CellExport["CellExportTestTag", ExportFormat -> ".eps"] *)

enbexport

Package

BeginPackage["CellExport`"];

enbexport;

CellExport; TagProperties; CellFilter; ExportBaseFilename; ExportFormat; ExportOptions; Split;

Begin["Private`"];

styledefinitions=Cell[StyleData[All, "Working"],ShowSyntaxStyles->True];

HackedExport[fname_String, rest___] := Module[{out},
If[FileExtension[fname]=!="png",
Export[fname, rest],
Export["HackedExportTemporary.gif", rest];
out=Export[fname, Import["HackedExportTemporary.gif"]];
DeleteFile["HackedExportTemporary.gif"];
out
]
];

TagProperties[_] := {};
Options[CellExport] = {
PageWidth -> 6, CellFilter -> Identity, ExportBaseFilename -> Automatic, ExportFormat -> ".pdf", ExportOptions -> {}, Split -> False
};
CellExport[tag_String, opts___Rule] := CellExport[
NotebookGet[EvaluationNotebook[]],
tag, opts
];
CellExport[nb_Notebook, tag_String] := CellExport[nb, tag, TagProperties[tag]];
CellExport[nb_Notebook, tag_String, OptionsPattern[]] := Module[
{cells, cell, filename, format, enb},
filename = OptionValue[ExportBaseFilename] /. Automatic -> tag;
format=OptionValue[ExportFormat];
Print["exporting ",tag," into ", filename<>format,"..."];
cells=OptionValue[CellFilter][Cases[
nb, c_Cell /; FreeQ[List@@c, Cell] && !FreeQ[c, CellTags->tag],
Infinity
]];
If[!OptionValue[Split],
If[Length[cells]≥1,
If[Length[cells]==1,
cells=Append[First[cells], PageWidth -> 72OptionValue[PageWidth]],
cells=Cell[CellGroup[cells], PageWidth -> 72OptionValue[PageWidth]]
];
enbexport=enb=Notebook[{cells}, StyleDefinitions-> styledefinitions, PrintingStyleEnvironment->"Working"];
HackedExport[
filename<>format,enb,
ImageResolution -> 300,
OptionValue[ExportOptions]
]
],
k=0;
Table[
++k;
enbexport=enb=Notebook[{
Append[cell, PageWidth -> 72OptionValue[PageWidth]],
 StyleDefinitions-> styledefinitions
}];
HackedExport[
filename<>"-"<>ToString[k]<>format,
enb,
ImageResolution -> 300,
OptionValue[ExportOptions]
],
{cell, cells}
]
]
];

End[]; EndPackage[];