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 an outline as a set of data, then it’s easy to understand that an outline’s data can be packaged in a variety of ways. Each “data package” has a set of parameters that determine how the outline data is stored or presented.

For example, one package may store the data as tabbed data, while another may store the outline 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 FileWrapper has a unique type identifier that identifies that wrapper. To get a list of the export types supported by OmniOutliner, 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:

document.writableTypes.join("\n")

A writable type is used when creating a new file wrapper instance:

wrapper = document.fileWrapper('com.Adobe.pdf')

IMMPORTANT: the previously used fileWrapper(…) function has been deprecated in favor of the makeFileWrapper(…) function, which returns a JavaScript Promise object as its result:

wrapperPromise = document.makeFileWrapper('My File Name', 'public.comma-separated-values-text') wrapperPromise.then(function(wrapper){ console.log(wrapper) })

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

wrapperPromise = document.makeFileWrapper('My File Name') wrapperPromise.then(function(wrapper){ console.log(wrapper) })

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 outline data, which can be manipulated using class and instance functions from the Data class.

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

var docName = document.name wrapperPromise = document.makeFileWrapper(docName, 'public.png') wrapperPromise.then(function(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(function(result){console.log(result)}) })
omniplan://localhost/omnijs-run?script=try%7Bvar%20docName%20%3D%20document%2Ename%0AwrapperPromise%20%3D%20document%2EmakeFileWrapper%28docName%2C%20%27public%2Epng%27%29%0AwrapperPromise%2Ethen%28function%28wrapper%29%7B%0A%09encodedData%20%3D%20wrapper%2Econtents%2EtoBase64%28%29%0A%09taskName%20%3D%20encodeURIComponent%28docName%29%0A%09attachmentName%20%3D%20taskName%20%2B%20%22%2Epng%22%0A%09urlStr%20%3D%20%22omnifocus%3A%2F%2Flocalhost%2Fadd%3Fname%3D%22%20%2B%20taskName%20%2B%20%22%26attachment%3D%22%20%2B%20encodedData%20%2B%20%22%26attachment%2Dname%3D%22%20%2B%20attachmentName%0A%09URL%2EfromString%28urlStr%29%2Ecall%28function%28result%29%7Bconsole%2Elog%28result%29%7D%29%0A%7D%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D

 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

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:

docName = document.name PNGwrapperPromise = document.makeFileWrapper(docName, "public.png") PDFwrapperPromise = document.makeFileWrapper(docName, "public.jpeg") promises = [PNGwrapperPromise,PDFwrapperPromise] Promise.all(promises).then(function(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(function(urlObj){ console.log(urlObj.string) // file url to directory }) fileSaverPromise.catch(function(err){ console.log(err.message) }) }).catch(function(err){ console.log("Error", err.message) })
omniplan://localhost/omnijs-run?script=try%7BdocName%20%3D%20document%2Ename%0A%0APNGwrapperPromise%20%3D%20document%2EmakeFileWrapper%28docName%2C%20%22public%2Epng%22%29%0APDFwrapperPromise%20%3D%20document%2EmakeFileWrapper%28docName%2C%20%22public%2Ejpeg%22%29%0Apromises%20%3D%20%5BPNGwrapperPromise%2CPDFwrapperPromise%5D%0A%0APromise%2Eall%28promises%29%2Ethen%28function%28fileWrappers%29%7B%0A%0A%09filesaver%20%3D%20new%20FileSaver%28%29%0A%09folderType%20%3D%20new%20FileType%28%22public%2Efolder%22%29%0A%09filesaver%2Etypes%20%3D%20%5BfolderType%2C%20FileType%2Epng%2C%20FileType%2Ejpeg%5D%0A%09fldrwrapper%20%3D%20FileWrapper%2EwithChildren%28%22Export%20Folder%22%2CfileWrappers%29%0A%09fileSaverPromise%20%3D%20filesaver%2Eshow%28fldrwrapper%29%0A%0A%09fileSaverPromise%2Ethen%28function%28urlObj%29%7B%0A%09%09console%2Elog%28urlObj%2Estring%29%20%2F%2F%20file%20url%20to%20directory%0A%09%7D%29%0A%0A%09fileSaverPromise%2Ecatch%28function%28err%29%7B%0A%09%09console%2Elog%28err%2Emessage%29%0A%09%7D%29%0A%09%0A%7D%29%2Ecatch%28function%28error%29%7B%0A%09console%2Elog%28%22Error%22%2C%20error%2Emessage%29%0A%7D%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D

FileWrapper.Type

The class properties of a FileWrapper.Type:

As mentioned previously, here is a full explanation of the FileWrapper.Types supported by OmniPlan:

Here are the various export formats with their corresponding FileWrapper.Type:

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
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
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.
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(function(err){ console.log(err.message) }) }).catch(function(error){ console.error(error.message) })
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

 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.

UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER