Computable Document Format (CDF) files supply a rich deployment method leveraging the power and flexibility of the Wolfram Language with the potential for wide distribution provided by a public format and a free player. As a built-in feature of the Wolfram Language, it's easy to save .cdf files straight from your working notebooks, custom-formatted papers and articles, or dedicated application development workflows. Almost anything you compute in the Wolfram Language can be made into a user-interactive object offering maximum clarity in the presentation of your concepts as a CDF file viewed with Wolfram CDF Player.
Computable Document Format files can be created from existing notebooks or from scratch. They can contain absolutely anything you can put into a Wolfram System notebook. Begin a CDF file as you would any notebook by selecting File ▶ New.
The main difference between a Wolfram System 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 only viewable as static documents in CDF Player, but Manipulate objects (or other dynamic elements) in a .cdf file remain fully interactive when viewed in CDF Player.
Please see "Interactivity in .cdf Files" for further information on how best to take advantage of CDF interactive features.
The primary deployment method for converting a notebook to CDF is to select the CDF Export menu item, which offers a step-by-step interface for creating web-embeddable or stand-alone versions. See "Deploying a .cdf File" for additional details.
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.
- Wolfram Symbolic Transfer Protocol (WSTP) operations, including J/Link and .NET/Link, are not supported.
- 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: