Message Boards Message Boards

GROUPS:

Apply a stylesheet and set other style options for a CDF?

Posted 11 months ago
1769 Views
|
4 Replies
|
2 Total Likes
|

Hello everyone,

I'm creating a series of student exams using a loop, CreateDocument, NotebookWrite, and CDFDeploy. Here is a code fragment (without exam questions) for creating one exam. It works well.

nb = CreateDocument[];
NotebookWrite[nb, Cell["EXAM", "Title"]];
NotebookWrite[nb, Cell["More Here", "Chapter"]];
NotebookWrite[nb, Cell["", "Chapter"]];
NotebookWrite[nb, 
  Cell[DateString[{"DayName", ", ", "MonthName", " ", "Day", ", ", 
     "Year",
     "  ", "Hour12Short", ":", "Minute", " ", "AMPM"}], "Text"]];
NotebookWrite[nb, Cell["INSTRUCTIONS", "Text"]];
NotebookWrite[nb, Cell["", "Text"]];
(*Exam questions to go here*)
NotebookWrite[nb, 
 Cell[BoxData[ToBoxes[Array[a, {5, 6}]]], "Print"], After]
CDFDeploy["/myPath/Prototype Exam.cdf", nb]
NotebookClose[nb];

I need advice on styling the CDFs. The CDF file that is produced by CreateDocument and CDFDeploy uses the default stylesheet. (1) How can I make the CDF adopt the cell styling or stylesheet of the notebook that I am using to create the CDFs? I know I can wrap each output cell in Style but that is a pain. (2) How can I set an option in the CDF so that all output is displayed in TraditionalForm? The default output is standardForm. (3) Is there some way to disable the Print menu item and Print button that appears in the CDF when opened in Wolfram Player? I posted this last question some time ago, and the response was that there isn't, but I am asking again just in case the most recent version of Mathematica includes that capability.

Regards,

Greg

4 Replies
Posted 11 months ago

In regards to (1), I create my CDFs by creating a notebook with CreateDocument and using the StyleDefinitions option with the contents of the custom stylesheet. You can just use Get to read the styles.

Something like:

styles = Get["your_custom_stylesheet.nb"];
nb = CreateDocument[(...), StyleDefinitions->styles];
CDFDeploy["file.cdf", nb, "Target" -> "PlayerPro"]

Thanks Gustavo, Where does Mathematica save private style definitions files? Greg

Posted 11 months ago

I have something like this:

styles = Get @ FileNameJoin @ {$UserBaseDirectory, "SystemFiles", "FrontEnd", "StyleSheets", "YourCustomStyleSheet.nb"};

Thanks once again, Gustavo. Got it. Just had to feed Save As the path to the hidden directory.

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