OneNote Documents Conversion to HTML with Aspose.Note for Java 18.1

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Aspose-Note-for-JavaWe are pleased to announce the release of Aspose.Note for Java 18.1. This method includes a new feature of exporting OneNote data to HTML file format. Documents can also be saved to Html format in Byte array. For a complete list of what is new and fixed, please visit the release notes section of the API.

Saving OneNote Documents as HTML using Aspose.Note for Java

This latest release of Aspose.Note for Java introduces the capability of converting OneNote documents to Html file format. This is a long-awaited feature that was in our To-Do list for quite some time. The implementation of this feature lets you save OneNote documents to file on disc as well as output Byte array. The feature is available in the following three variants.

Saving to Byte Array with Embedded Resources

Document document = new Document(dataDir + "Sample1.one");
		
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportCss(ResourceExportType.ExportEmbedded);
options.setExportImages(ResourceExportType.ExportEmbedded);
options.setExportFonts(ResourceExportType.ExportEmbedded);
options.setFontFaceTypes(FontFaceType.Ttf);
 
ByteArrayOutputStream r = new ByteArrayOutputStream();
document.save(r, options);

Save to Byte Arrary with Callbacks

Document document = new Document(dataDir + "Sample1.one");
		
UserSavingCallbacks savingCallbacks = new UserSavingCallbacks();
savingCallbacks.setRootFolder(dataDir);
savingCallbacks.setCssFolder("css");
savingCallbacks.setKeepCssStreamOpened(true);
savingCallbacks.setImagesFolder("images");
savingCallbacks.setFontsFolder("fonts");
	 
HtmlSaveOptions options = new HtmlSaveOptions();
options.setFontFaceTypes(FontFaceType.Ttf);
options.setCssSavingCallback(savingCallbacks);
options.setImageSavingCallback(savingCallbacks);
options.setFontSavingCallback(savingCallbacks);
options.setExportCss(ResourceExportType.ExportAsFile);
options.setExportImages(ResourceExportType.ExportAsFile);
options.setExportFonts(ResourceExportType.ExportAsFile);
	 
File dir = new File(savingCallbacks.getRootFolder());
if (!dir.exists())
{
 dir.mkdir();
}
	 
document.save(Paths.get(savingCallbacks.getRootFolder(), "document.html").toString(), options);
try (OutputStreamWriter writer = new OutputStreamWriter(savingCallbacks.getCssStream(), "utf-8")){
 writer.write(System.lineSeparator());
 writer.write("/* This line is appended to stream manually by user */");
 writer.close();
}

Save to File With Resources in Separate Files

Document document = new Document(dataDir + "Aspose.one");
		
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportCss(ResourceExportType.ExportAsFile);
options.setExportFonts(ResourceExportType.ExportAsFile);
options.setExportImages(ResourceExportType.ExportAsFile);
	 
document.save(dataDir + "document.html", options);

API Resources

  • Documentation – Visit our documentation section for getting started with the API in no time
  • API Reference Guide – Gives detailed information about all the namespaces, classes and methods of the API
  • Forum Support – Post your queries on Aspose.Note forum to get assistance from our technical support team
  • GitHub Examples – Try the ready-to-use examples of the API by downloading from our GitHub repository

To keep up with our news, you can follow us on Twitter or follow our Facebook page.

Leave a Reply