public void takeScreenshotOfDocument(String documentFileName) { File documentFile = new File(documentFileName); File documentDirectory = documentFile.getParentFile(); String imageName = FileUtils.getBaseName(documentFile.getName()) + ".png"; File screenshotFile = new File(documentDirectory, imageName); NodeBoxDocument doc = NodeBoxDocument.load(documentFile); addDocument(doc); doc.setVisible(true); doc.takeScreenshot(screenshotFile); doc.close(); }