Search code examples
xpsonenote

Programmatically convert OneNote sections to XPS


I need a way to programmatically convert OneNote sections files (.one) to XPS format. I know how it works for Excel and Word, but Interop.OneNote is different.


Solution

  • You would use the Publish function (http://msdn.microsoft.com/en-us/library/gg649853.aspx), e.g.:

    using Microsoft.Office.Interop.Onenote;
    
    ...
    
    Application onApp = new Application();
    string sectionid = "your section id here..."; //could also be a page or notebook id
    string path = "your filepath here..."; //e.g. C:\Users\MyUsername\Documents\hi.xps
    onApp.Publish(sectionid, path, PublishFormat.pfXPS);