Computable Document Format (CDF) files supply a rich deployment method leveraging the power and flexibility of the Mathematica language with the wide distribution provided by a public format. As a built-in feature of Mathematica 8, it's easy to save .cdf files straight from your working notebooks, custom-formatted papers and articles, or dedicated application development workflows. Anything you compute in Mathematica can be made into a user-interactive object offering maximum clarity in the presentation of your concepts, and there are no special considerations when creating documents just for viewing in Wolfram CDF Player; all notebook features can be displayed and printed.
The main difference between a Mathematica notebook and a .cdf file is the allowance of interaction when viewing your document in CDF Player. Notebook files (files with the extension .nb) are viewable as static documents in CDF Player, but any Manipulate objects present in a .cdf file are fully interactive in CDF Player.
Not all content in a .cdf file created this way is interactive, however. Please see "Interactivity in .cdf Files" for further information.
An open notebook can also be made into a .cdf file in one of two ways. The first method uses the Save As menu, while the second method uses the CDF Export menu item. For more information on the CDF Export menu item or how to embed a .cdf file into existing HTML, see "Deploying a .cdf File".
To create a .cdf file from this notebook expression, use Export just as you would with any other file format:
Follow the instructions in the wizard to save a standalone .cdf file. Note that if you want to save a selection from a notebook instead of the entire window, you must select the portion to be deployed before opening the wizard.
The wizard will walk you through the steps of saving the .cdf file from an entire document or a selected portion, specifying where on your web server the .cdf file will be located, and then it will provide an HTML code segment to be copied and pasted into an existing HTML file. Note that, as with the standalone file, if you want to save a selection from a notebook instead of the entire window, you must select the portion to be deployed before opening the wizard.
- All interactive content must be generated with the Manipulate command and may only use mouse-driven elements, such as Slider, Locator, Checkbox, PopupMenu, etc.
- Data import and export are not supported from within CDF Player with the exception of Wolfram-curated data sources (ChemicalData, CountryData, WordData, etc.).
Because CDF Player cannot load custom data at runtime, you must ensure that all necessary information is embedded within the interactive elements of your .cdf file. This can be done with either Initialization or SaveDefinitions; both are options to Manipulate.
The Initialization option can be used to include small blocks of code and data in the interactive output, as in this simple example:
Alternatively, for larger blocks of code, packages, or larger datasets, it may be more convenient to define them before creating the Manipulate output, then store their state within the output using the SaveDefinitions option. The simple example below recreates the above example without using Initialization: