Message Boards Message Boards


Is possible to join CDF files?

Posted 10 years ago
6 Replies
3 Total Likes
Hi all!

I am writing a textbook on seismic hazard analysis in Mathematica using some of Eric Schulzes tools. Currently each section is a single CDF file.  Does anybody know a way to join them so that I can generate  one CDF file,  without having to join the underlying notebooks?
POSTED BY: Frank Scherbaum
6 Replies

At the most basic level, to create a notebook navigator as Eric Schulzes did in his Calculus textbook work is to create a dockedCell with an ActionMenu where the menu items execute a function like (assuming that all of the notebooks are in the same directory)

SystemOpen[FileNameJoin[{NotebookDirectory[], "NotebookA.cdf"}]]

And if one were to want to close the notebook that executes that menu item one could write it as

SystemOpen[FileNameJoin[{NotebookDirectory[], "DrugExclusionScriptIdeas.nb"}]];NotebookClose[EvaluationNotebook[]
POSTED BY: David Reiss

Hi Frank. If the ebookUtilities package is still available I would like to receive a copy. Thank you for sharing. Best. Mark

POSTED BY: Mark McBride

Hi Frank, I too am interested in the ebookUtilities package. Would it be possible to send the resources to ? Best Wishes, Steve

POSTED BY: Steven Metcalfe
Thanks, you perfectly address what I want to do. I already do use the navigation bar within the docked cell (which you show above) to move around within a section file. The way this is done is shown below.  I got the code to set up the navigation menu in the docked cell from Tom Wickham Jones.

 (* *************************************************************************************** *) CreateLinks[nb_] := Module[{tagLis = {},data},  SelectionMove[nb, Before, Notebook];  While[(SelectionMove[nb, Next, Cell];      data = NotebookRead[nb]) =!= {},   tagLis = Join[tagLis, Cases[data, Rule[CellTags, tg_] :> tg]]];  MapThread[#1 :> {NotebookLocate[#1],       FrontEndExecute[{FrontEndToken[         "SelectionOpenAllGroups"]}]} &, {tagLis}]]          (* *************************************************************************************** *) Options[BuildDockedCell] = {dockedcellcontent -> Cell[TextData[{"Tutorials on Probabilistic Seismic Hazard Analysis", StyleBox["\nFrank Scherbaum ", FontSize -> 14],     StyleBox["  University of Potsdam", FontSize -> 12, FontSlant -> "Italic"]}], FontFamily -> "Helvetica",     CellMargins -> {{0, 0}, {0, 0}}, TextAlignment -> -0.5`, FontSize -> 20, FontColor -> ColorData["HTML"]["Gold"], Background -> ColorData["HTML"]["MidnightBlue"]],    navigationMenuHeader->"Figures",manuscriptdir->$HomeDirectory};    BuildDockedCell[manuscriptname_, opts : OptionsPattern[]] := Module[{nb, dcell1, menucell},  SetOptions[OpenManuscript,FilterRules[{Options[BuildDockedCell]},Options[OpenManuscript]]];  SetOptions[OpenManuscript,FilterRules[{opts},Options[OpenManuscript]]];   nb = OpenManuscript[manuscriptname];    dcell1 = OptionValue[dockedcellcontent];  If[dcell1 =!= None,  menucell = Cell[BoxData@ToBoxes@Grid[{{         ActionMenu[          Row[{OptionValue[navigationMenuHeader]}],          CreateLinks[nb],          ImageSize -> {85,25},          ImageMargins -> 0, FrameMargins -> 0,           BaseStyle -> {"MSG", 12}]}},       Spacings -> {0.5, 0.5}, Alignment -> {Left, Top}],    "DockedCell", Background -> GrayLevel[0.95]];  SetOptions[nb,DockedCells -> {dcell1, menucell}],  SetOptions[nb,DockedCells ->Inherited]];  nb ]    (* *************************************************************************************** *)   Options[BuildDockedCellWithGoBackButton] = {dockedcellcontent -> Cell[TextData[{"Tutorials on Probabilistic Seismic Hazard Analysis", StyleBox["\nFrank Scherbaum ", FontSize -> 14],     StyleBox["  University of Potsdam", FontSize -> 12, FontSlant -> "Italic"]}], FontFamily -> "Helvetica",     CellMargins -> {{0, 0}, {0, 0}}, TextAlignment -> -0.5`, FontSize -> 20, FontColor -> ColorData["HTML"]["Gold"], Background -> ColorData["HTML"]["MidnightBlue"]],    navigationMenuHeader->"Figures",manuscriptdir->$HomeDirectory};     BuildDockedCellWithGoBackButton[manuscriptname_,opts:OptionsPattern[]] :=  Module[{nb, dcell1, gobackbutton, goforwardbutton,menuitem},  SetOptions[OpenManuscript,FilterRules[{Options[BuildDockedCellWithGoBackButton]},Options[OpenManuscript]]];  SetOptions[OpenManuscript,FilterRules[{opts},Options[OpenManuscript]]];    nb = OpenManuscript[manuscriptname];    dcell1 = OptionValue[dockedcellcontent];  If[dcell1 =!= None,  menuitem = Grid[{{      ActionMenu[       Row[{OptionValue[navigationMenuHeader]}],       CreateLinks[nb],       ImageSize -> {85,25},       ImageMargins -> 0, FrameMargins -> 0,        BaseStyle -> {"MSG", 12}]}},    Spacings -> {0.5, 0.5}, Alignment -> {Left, Top}    ];  gobackbutton =    Button["<",     FrontEnd`FrontEndExecute[     FrontEnd`FrontEndToken[ButtonNotebook[], "HyperlinkGoBack"]],     Evaluator -> None];  goforwardbutton =    Button[">",     FrontEnd`FrontEndExecute[     FrontEnd`FrontEndToken[ButtonNotebook[], "HyperlinkGoForward"]],     Evaluator -> None];    SetOptions[nb,   DockedCells -> {dcell1,      Cell[BoxData[       ToBoxes[Row[{gobackbutton, goforwardbutton, " ", menuitem}]]],       "DockedCell", Background -> GrayLevel[0.95]]}]      ,   SetOptions[nb,DockedCells ->Inherited]];   nb]
For my workflow, I simply wanted to check each section file in the CDF player  separately but then put them together into a single book file. I haven´t yet checked if this makes sense at all. 

By the way, for my own workflow, I have generated eBookUtilities package which contains all the material I collected (primarily from Eric Schulz and Tom Wickham Jones) for this purpose. It now contains quite a bit of stuff which I no longe ruse since my workflow has changed quite a bit but  some of it may be interesting for others .  I´d be happy to share it with anybody who is interested but it may need some QA. Below is the main guide page. 
 This is a collection of tools to facilitate  the production of electronic books using Mathematica. Starting point was the material genererously shared by  Eric Schulz and which was  presented at the Wolfram Technology Conference 2011 in his presentation  Sharing Wisdom Gained From Publishing a CDF eBook. 
 updateStylesheet \[LongDash] updates the style sheets in a list of notebooks 
 MakeCombinedManuscript \[LongDash] generates a combined manuscript notebook (with all material from file supportfilename)
 MakeCleanManuscript \[LongDash] generates a cleaned manuscript notebook file from which output cells, etc. are removed 
 MakeCleanCDF \[LongDash] generates clean  CDF from the combined manuscript notebook 
 SaveNotebookAsCleanCDF \[LongDash] saves input notebook directly as clean CDF with docked cell
 BuildDockedCell \[FilledVerySmallSquare] BuildDockedCellWithGoBackButton \[FilledVerySmallSquare] CDFdir . CloseManuscript \[FilledVerySmallSquare] CloseSupport \[FilledVerySmallSquare] combinedCleanNBdir \[FilledVerySmallSquare] combinedNBdir \[FilledVerySmallSquare] dockedcellcontent \[FilledVerySmallSquare] CreateFigureCell \[FilledVerySmallSquare] CreateImageCell \[FilledVerySmallSquare] CreateLinks \[FilledVerySmallSquare] CreateTableCell \[FilledVerySmallSquare] DeleteDockedCell \[FilledVerySmallSquare] EvaluateManuscript \[FilledVerySmallSquare] EvaluateSupport \[FilledVerySmallSquare] MakeCleanCDF \[FilledVerySmallSquare] MakeCleanManuscript \[FilledVerySmallSquare] makeCleanUpPalette \[FilledVerySmallSquare] MakeCombinedManuscript \[FilledVerySmallSquare] makeHideCodePalette \[FilledVerySmallSquare] makePrivateFontsPalette \[FilledVerySmallSquare] manuscriptdir \[FilledVerySmallSquare] navigationMenuHeader \[FilledVerySmallSquare] NumberOfColors \[FilledVerySmallSquare] OpenManuscript \[FilledVerySmallSquare] OpenSupport \[FilledVerySmallSquare] SaveManuscript \[FilledVerySmallSquare] SaveNotebookAsCleanCDF \[FilledVerySmallSquare] SaveSupport \[FilledVerySmallSquare] setAutoReplacements . stylesheetdir \[FilledVerySmallSquare] stylesheetfile \[FilledVerySmallSquare] supportfiledir \[FilledVerySmallSquare] updateCurrentStylesheet \[FilledVerySmallSquare] updateStylesheet 
How to organize the writing process
Link to chapter 3 secton 1
POSTED BY: Frank Scherbaum

Hi Frank,

I am interested in the eBookUtilities package which contains material you collected Eric and Tom. I've watched Eric's video and I am very interested in learning more. Would you mind sending me this information/notebook?

POSTED BY: Michael McCain
This quite interesting question from the perspective of CDF. Technically joining CDF files programmatically is as easy as joining notebooks, but I am not entirely sure it is what you meant. But first things first, I'd like to point out that you probably refer to the following Eric's talk: Publishing a CDF ebook: an Author's Perspective Download notebook ( slideshow ) which is about the following CDF textbook he created: Calculus: Early Transcendentals .

So technically you could join CDF files as follows. Let me save to hardrive 2 different CDF files to a default directory:

CDFDeploy["Notebook1.cdf", DocumentNotebook[{ExpressionCell[Manipulate[foo, {foo, 0, 1}]]}]];
CDFDeploy["Notebook2.cdf", DocumentNotebook[{ExpressionCell[Manipulate[bar, {bar, 0, 1}]]}]];
Now this basically gets the cells from these CDF files and then merges them in a notebook and deploys it as new CDF file on your harddrive:

get1 = NotebookGet[NotebookOpen["Notebook1.cdf"]];
get2 = NotebookGet[NotebookOpen["Notebook2.cdf"]];
CDFDeploy["Notebook.cdf", NotebookPut[Notebook @@ ({get1[[1]]~Join~get2[[1]]}~Join~Options[get1])]];

But if I personally was creating a large textbook, I would merge it as Eric did - by calling to separate chapters. As yo u can see on the image below there is a top menu to call to various parts of the textbook (I am not entirely sure how he implemented tis. Maybe someone else can comment on that.):

POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract