How to | Create a Computable Document Format (CDF) File

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.

For example, users viewing your CDF document using CDF Player will be able to move the sliders interactively:

Click for copyable input
Out[1]=Play Animation

Interactive and static content can be mixed freely in a .cdf file. For instance, you can include standard document features such as section headers:

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.

To use the Save As menu, select your open notebook in the Wolfram System and then select File Save As...:

Then select Computable Document (*.cdf) from the drop-down menu labeled Save as type: in the file browser window that appears:

Other programmatical methods for creating a CDF files include CDFDeploy and Export (both Import and Export fully support the "CDF" file format).

Deploying a .cdf File

Using the File CDF Export menu item, you can either save a .cdf file as a standalone document or easily embed either the entire document or a specific selection into existing HTML code.

To create a standalone .cdf file, select the menu item File CDF Export Standalone...:

Upon clicking the menu item, the following window will appear:

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.


If you want to create a .cdf file to be embedded in a web page, select the menu item File CDF Export Web Embeddable...:

Upon clicking the menu item, the following window will appear:

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.

Interactivity in .cdf Files

Almost all of the functions available in the Wolfram Language can be used to build applications for CDF Player, but there are a few programming restrictions to keep in mind.


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:

Click for copyable input

For activation of higher-level application content in .cdf files, such as arbitrary input, dialog windows, and loading external data, please contact Wolfram Research.

See Also

CDF  CDFDeploy  CDFInformation