// Prepare HTML code and save it to a file
String code = "Hello, World!!";
try (java.io.FileWriter fileWriter = new java.io.FileWriter("document.html")) {
fileWriter.write(code);
}
// Initialize an HTML document from the file
HTMLDocument document = new HTMLDocument("canvas.html");
// Initialize XpsSaveOptions
XpsSaveOptions options = new XpsSaveOptions();
// Convert HTML to XPS
Converter.convertHTML(document, options, "canvas-output.xps");