×

Document Export

OmniPlan supports the export of documents to files of various formats. This section examines how to create File Wrappers in preparation for the export of documents and content.

Documentation regarding the other classes involved in the saving and export of OmniPlan documents can be found in FileTypes and FileSavers.

FileWrappers

If you think of a project as a set of data, then it’s easy to understand that a project’s data can be packaged in a variety of ways. Each “data package” has a set of parameters that determine how the project data is stored or presented.

For example, one package may store the data as tabbed data, while another may store the project data in XML format. Each of the supported file packaging formats has its own set of parameters. In terms of Omni Automation, these file packages are referred to as FileWrappers.

Each instance of the FileWrapper class has a unique type identifier that identifies that wrapper. To get a list of the export types supported by OmniPlan, write a simple script to access the value of the writableTypes property of the Document class. The result will be an array of the identifiers for the FileWrappers supported in OmniPlan:

OmniPlan Writable Types Identifiers


document.writableTypes //--> ["com.omnigroup.omniplan2.planfile-zip", "com.omnigroup.omniplan2.planfile", "com.apple.ical.ics", "public.comma-separated-values-text", "com.microsoft.mpp", "com.microsoft.project.mspdi", "public.png", "com.adobe.pdf", "public.tiff", "public.jpeg", "com.omnigroup.omnioutliner.xmlooutline", "com.omnigroup.foreign-types.graphviz-gv"]

A variation of the previous script that returns the types as a multi-line text block:

OmniPlan Writable Types Identifiers


document.writableTypes.join("\n") //--> "com.omnigroup.omniplan2.planfile-zip com.omnigroup.omniplan2.planfile com.apple.ical.ics public.comma-separated-values-text com.microsoft.mpp com.microsoft.project.mspdi public.png com.adobe.pdf public.tiff public.jpeg com.omnigroup.omnioutliner.xmlooutline com.omnigroup.foreign-types.graphviz-gv"

A writable type identifier is used when creating a new file wrapper instance with the makeFileWrapper() function:

Make File Wrapper of Specified Type


var fileName = "My File Name" var typeID = "public.comma-separated-values-text" var wrapperPromise = document.makeFileWrapper(fileName, typeID) wrapperPromise.then(wrapper => { console.log(wrapper) //--> [object FileWrapper: file, 682 bytes] }) wrapperPromise.catch(err => { console.error(err.message) })

NOTE: If the document identifier parameter is omitted from the makeFileWrapper(…) function, the default document type (OmniPlan Document (.oplx)) is automatically used.

Make Default File Wrapper


var wrapperPromise = document.makeFileWrapper("My File Name") wrapperPromise.then(wrapper => { console.log(wrapper) //--> [object FileWrapper: file, 682 bytes] })

Instance Properties

Each FileWrapper instance has a set of supported properties, most of which have values that are read-only, with the exception of the preferredFilename property whose value can be set in a script.

The value of the contents property is a representation of the project data, which can be manipulated using class and instance functions from the Data class.

For example, here’s an example of exporting the current data view to a new OmniFocus task as a PNG image:

Add OmniPlan Snap to New OmniFocus Task


docName = document.name wrapperPromise = document.makeFileWrapper(docName, "public.png") wrapperPromise.then(wrapper => { encodedData = wrapper.contents.toBase64() taskName = encodeURIComponent(docName) attachmentName = taskName + ".png" urlStr = "omnifocus://localhost/add?name=" + taskName + "&attachment=" + encodedData + "&attachment-name=" + attachmentName URL.fromString(urlStr).call(result => { console.log(result) //--> "omnifocus:///task/eb1BMyUGr2F" }) })

 01  Store the name of the OmniPlan document.

 02  Call the makeFileWrapper(…) function on the Document class, passing in the stored document name nas the name for the created file, and "public.png" as the file type identifier. The resulting JavaScript Promise object is stored in the variable: wrapperPromise

 03-09  The promise object is resolved by calling the then(…) function on the stored instance. By default, the call-back function will be provided the created file wrapper instance as its default passed parameter.

 04  The value provided by the wrapper’s contents property is converted into a base-64 encoded string using the toBase64() function of the Data class.

 05  The document name is URL encoded to be used as the title of the created OmniFocus task.

 06  The image attachment file name is the same as the task name with the ".png" file extension appended to it.

 07  The OmniFocus URL string is generated by inserted the stored data after the named parameters.

 08  The OmniFocus URL string is converted into a URL object, and the new url is executed using the call() method. The result of the task creation will be a URL link to the created task, similar to: omnifocus:///task/p6zgTDGjLt0

NOTE: To create the new task without returning a result to OmniPlan, use the open() function of the URL class instead of the call() function:

OmniPlan Snap to New OmniFocus Task (no return result)


docName = document.name wrapperPromise = document.makeFileWrapper(docName, "public.png") wrapperPromise.then(wrapper => { encodedData = wrapper.contents.toBase64() taskName = encodeURIComponent(docName) attachmentName = taskName + ".png" urlStr = "omnifocus://localhost/add?name=" + taskName + "&attachment=" + encodedData + "&attachment-name=" + attachmentName URL.fromString(urlStr).open() })

Class Functions

The class functions for the FileWrapper class:

Instance Functions

The instance functions for the FileWrapper class:

The following example uses the FileWrapper.withChildren(…) function to generate a new folder containing mutliple image export files. Note the use of the Promise.all() function to handle mutliple instances of file wrapper promises:

Multiple Exports


var docName = document.name PNGwrapperPromise = document.makeFileWrapper(docName, "public.png") JPGwrapperPromise = document.makeFileWrapper(docName, "public.jpeg") promises = [PNGwrapperPromise, JPGwrapperPromise] Promise.all(promises).then(fileWrappers => { filesaver = new FileSaver() folderType = new FileType("public.folder") filesaver.types = [folderType, FileType.png, FileType.jpeg] fldrwrapper = FileWrapper.withChildren("Export Folder", fileWrappers) fileSaverPromise = filesaver.show(fldrwrapper) fileSaverPromise.then(urlObj => ){ console.log(urlObj.string) // file url to directory urlObj.open() // on macOS open the directory }) fileSaverPromise.catch(function(err){ console.error("Error", err.message) }) }).catch(function(err){ console.error("Error", err.message) })

PRO TIP: For those with a more advanced knowledge of JavaScript, here is the previous multiple export types script written using await statements within an asynchronous function wrapper as an alternative to explicit Promise blocks:

omniplan://localhost/omnijs-run?script=%28async%20%28%29%20%3D%3E%20%7B%0A%09try%20%7B%0A%09%09let%20docName%20%3D%20document%2Ename%0A%09%09let%20PNGwrapper%20%3D%20await%20document%2EmakeFileWrapper%28docName%2C%20%22public%2Epng%22%29%0A%09%09let%20JPGwrapper%20%3D%20await%20document%2EmakeFileWrapper%28docName%2C%20%22public%2Ejpeg%22%29%0A%09%09let%20filesaver%20%3D%20new%20FileSaver%28%29%0A%09%09let%20folderType%20%3D%20new%20FileType%28%22public%2Efolder%22%29%0A%09%09filesaver%2Etypes%20%3D%20%5BfolderType%2C%20FileType%2Epng%2C%20FileType%2Ejpeg%5D%0A%09%09let%20fldrwrapper%20%3D%20FileWrapper%2EwithChildren%28%22Export%20Folder%22%2C%20%5BPNGwrapper%2C%20JPGwrapper%5D%29%0A%09%09let%20savedURL%20%3D%20await%20filesaver%2Eshow%28fldrwrapper%29%0A%09%09savedURL%2Eopen%28%29%0A%09%7D%0A%09catch%28err%29%7Bconsole%2Eerror%28err%29%7D%0A%7D%29%28%29%3B
Asynchronous Export
 

(async () => { try { docName = document.name PNGwrapper = await document.makeFileWrapper(docName, "public.png") JPGwrapper = await document.makeFileWrapper(docName, "public.jpeg") filesaver = new FileSaver() folderType = new FileType("public.folder") filesaver.types = [folderType, FileType.png, FileType.jpeg] fldrwrapper = FileWrapper.withChildren("Export Folder", [PNGwrapper, JPGwrapper]) savedURL = await filesaver.show(fldrwrapper) savedURL.open() } catch(err){console.error(err)} })();
 

FileWrapper.Type

The class properties of a FileWrapper.Type:

Here are descriptions of the FileWrapper.Types supported by OmniPlan:

OmniPlan Document (.oplx)
Of course, OmniPlan can export to its own format. This is useful when you want to use the filtering feature to make a new OmniPlan file of tasks matching certain criteria—just filter the tasks and make sure that Only Filtered Contents is checked when you go to export the project.
com.omnigroup.omniplan2.planfile
com.omnigroup.omniplan2.planfile-zip (New in OP 4.x)
iCalendar (.ics)
This is the calendar format used by Apple iCal, Apple Calendar, and many other calendar applications. You can choose to export the tasks as calendar events or as items on a to-do list. If you export calendar events, you can also choose whether each task should become to a single event, regardless of how long it may be (One event per task), or whether tasks should be broken into chunks when they span working and non-working hours (One event per work period).
com.apple.ical.ics
Comma Separated Values (.csv)
CSV is a common, plain-text format that can be read by many different applications. If you’re having trouble persuading other applications to read the non-ASCII characters in your CSV file, such as accented letters or non-Roman characters, try exporting with one of the other encoding options. This makes it easier for some applications to detect the correct encoding and interpret your characters properly.
public.comma-separated-values-text
Image Export (.png, .pdf, .tiff, .jpg)
You can export a picture of the task view or the resource view, whichever one is open in the main window. In the Export panel, you can choose whether the image should include the outline, the chart, or both.
public.png, public.tiff, public.jpeg
OmniOutliner (.oo3)
The task outline is exported as an OmniOutliner file (supported by OmniOutliner 3 and 4), with row hierarchy that corresponds to OmniPlan’s task groupings and columns corresponding to those available in OmniPlan’s Task View.
com.omnigroup.omnioutliner.oo3
OmniGraffle
There are several types of OmniGraffle export available across an array of diagram types and style. Available diagram types for export include:
Work Breakdown Structure—Tasks and groups are represented by a tree of objects. The connection lines in this diagram type represent the hierarchy of the task outline; dependency lines are not represented.
Activity-on-Node Network Diagram—Tasks are represented by objects, connected by dependency lines. While a Gantt chart emphasizes durations, this type of chart emphasizes the path of dependencies.
Activity-on-Arrow Network Diagram—Tasks are represented as lines between objects, with the title and duration of the task as a label on each line. Like the Activity-on-Node network diagram, this diagram type emphasizes dependencies.
When exporting to a Work Breakdown Structure or an Activity-on-Node network diagram, you can choose between two different node Styles: nodes that represent tasks as basic objects (which just show the task name) or as tables (which show the task name, assigned resources, start date and end date).
com.omnigroup.OmniPlan.graffle
Adobe PDF
Export to standard Adobe PDF file.
com.adobe.pdf
Microsoft Project Support (Pro)
Exports a .ooutline file, containing the textual data from the OmniGraffle canvas. Exporting to OmniOutliner works best for diagrams that adhere to a tree-like structure. OmniGraffle uses the connection lines between shapes to create the outline hierarchy.
com.microsoft.mpp, com.microsoft.project.mspdi
If you’re ever called upon to reach across the aisle and use OmniPlan in tandem with Microsoft Project, there’s good news—OmniPlan Pro supports both export to and import from the vast majority of Project file formats.
Documents in the Microsoft Project XML or MPP formats created with Microsoft Project versions 2003 through 2016 can be opened by OmniPlan Pro.
Along with importing from the most-used MS Project formats, OmniPlan Pro can output to them as well. The following Microsoft Project formats are supported:
Extensible Markup Language (XML) and Microsoft Project Plan (MPP) Microsoft Project 2003 to 2016 can read and write these formats. MPP is the preferred format for most interactions with modern versions of Microsoft Project; as an open standard, XML is useful for interaction with other applications as well.
NOTE: OmniPlan’s Microsoft Project MPP export is updated to be most highly compatible with the newest MPP format we support (that used by Microsoft Project 2016). MPP files generated by OmniPlan will still open in older versions of Microsoft Project, but may not be as fully readable to them. Older versions of Microsoft Project may prompt you to download an update or converter from Microsoft to support the newer file format exported by OmniPlan.
See the built-in OmniPlan Help documentation for details concerning Microsoft Project exports.

Example: Export to Microsoft Project

Here’s a script demonstrating the export of the current document in Microsoft Project format.

omniplan://localhost/omnijs-run?script=try%7BdocName%20%3D%20document%2Ename%20%0AwrapperPromise%20%3D%20document%2EmakeFileWrapper%28docName%2C%20%27com%2Emicrosoft%2Empp%27%29%0A%0AwrapperPromise%2Ethen%28function%28wrapper%29%7B%0A%09filesaver%20%3D%20new%20FileSaver%28%29%0A%09filetype%20%3D%20new%20FileType%28%27com%2Emicrosoft%2Empp%27%29%0A%09filesaver%2Etypes%20%3D%20%5Bfiletype%5D%0A%09fileSaverPromise%20%3D%20filesaver%2Eshow%28wrapper%29%0A%0A%09fileSaverPromise%2Ethen%28function%28urlObj%29%7B%0A%09%09console%2Elog%28urlObj%2Estring%29%20%2F%2F%20url%20to%20saved%20file%0A%09%7D%29%0A%0A%09fileSaverPromise%2Ecatch%28function%28err%29%7B%0A%09%09console%2Elog%28err%2Emessage%29%0A%09%7D%29%0A%7D%29%2Ecatch%28function%28error%29%7B%0A%09console%2Eerror%28error%2Emessage%29%0A%7D%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
Export to Microsoft Project Format
 

docName = document.name wrapperPromise = document.makeFileWrapper(docName, 'com.microsoft.mpp') wrapperPromise.then(function(wrapper){ filesaver = new FileSaver() filetype = new FileType('com.microsoft.mpp') filesaver.types = [filetype] fileSaverPromise = filesaver.show(wrapper) fileSaverPromise.then(function(urlObj){ console.log(urlObj.string) // url to saved file }) fileSaverPromise.catch(err => { console.error(err.message) }) }).catch(err => { console.error(err.message) })

 01  Store the name of the OmniPlan project file.

 02  A file wrapper is created using the makeFileWrapper(…) function, which is passed the Microsft Project file type identifier and the OmniPlan Project name as parameters. The function returns an instance of the JavaScript Promise class, which when resolved will provide the created file wrapper instance. The generated promise is stored in the variable: wrapperPromise

 04-17  The stored promise is resolved by calling the then(…) function on the stored instance. If the wrapper creation is successful, the method’s call-back function will be passed a reference to the created file wrapper.

 05  With the file wrapper created, the script can now display the file saver dialog to the user so they may provide the file name and saving location. A new instance of the FileSaver class is created and stored in the variable: filesaver

 06  Create and store an instance of the FileType class using the Microsoft Project file type identifier.

 07  The value of the types property of the FileSaver class is an array of file types to be exported. In this example the property value will be an array containing a single file type instance.

 08  The saving dialog is displayed by calling the show(…) function and passing in the stored file wrapper instance as the parameter. The result of the function call is a JavaScript Promise instance, which is stored in the variable: fileSaverPromise

 10-12  When the user completes the saver dialog, the stored fileSaverPromise will be resolved by calling the then(…) function will automatically be passed a URL object referencing the saved file. The passed url can be used to perform any follow-up processing with the created file.

 14-16  Should the user cancel the saving dialog or should a problem occur during the processing of writing the file, the defining error will be passed into the catch(…) function, allowing the script to deal with the issue.

 17-19  The catch(…) function call is appended to the wrapper promise resolution call, so that any problem in creating the file wrapper can be dealt with by the script.

PRO TIP: And here is the previous export script written using await statements within an asynchronous function wrapper as an alternative to explicit Promise blocks:

omniplan://localhost/omnijs-run?script=%28async%20%28%29%20%3D%3E%20%7B%0A%09try%20%7B%0A%09%09let%20docName%20%3D%20document%2Ename%20%0A%09%09let%20wrapper%20%3D%20await%20document%2EmakeFileWrapper%28docName%2C%20%27com%2Emicrosoft%2Empp%27%29%0A%09%09let%20filesaver%20%3D%20new%20FileSaver%28%29%0A%09%09let%20filetype%20%3D%20new%20FileType%28%27com%2Emicrosoft%2Empp%27%29%0A%09%09filesaver%2Etypes%20%3D%20%5Bfiletype%5D%0A%09%09let%20urlObj%20%3D%20await%20filesaver%2Eshow%28wrapper%29%0A%09%09console%2Elog%28urlObj%2Estring%29%0A%09%7D%0A%09catch%28err%29%7Bconsole%2Eerror%28err%29%7D%0A%7D%29%28%29%3B
Export to Microsoft Project Format (asynchronous)
 

(async () => { try { docName = document.name wrapper = await document.makeFileWrapper(docName, 'com.microsoft.mpp') filesaver = new FileSaver() filetype = new FileType('com.microsoft.mpp') filesaver.types = [filetype] urlObj = await filesaver.show(wrapper) console.log(urlObj.string) } catch(err){console.error(err)} })();