Skip to content

Instantly share code, notes, and snippets.

@tresf
Last active January 14, 2020 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tresf/d03a02826a0caabc3e55d5b994a24561 to your computer and use it in GitHub Desktop.
Save tresf/d03a02826a0caabc3e55d5b994a24561 to your computer and use it in GitHub Desktop.
package qz.printer.action;
import com.github.zafarkhaja.semver.Version;
import qz.common.Constants;
import qz.deploy.DeployUtilities;
import qz.utils.SystemUtilities;
import java.awt.image.BufferedImage;
import java.awt.print.Printable;
import java.io.File;
import java.util.Date;
public class PrintHTMLStub extends PrintImage implements PrintProcessor, Printable {
public static void main(String ... args) {
if (SystemUtilities.isJar() && Constants.JAVA_VERSION.greaterThanOrEqualTo(Version.valueOf("11.0.0"))) {
System.setProperty("java.library.path", new File(DeployUtilities.detectJarPath()).getParent() + "/libs/");
}
System.setProperty("java.library.path", "Z:\\tray\\lib\\javafx\\windows\\javafx-sdk-11.0.2\\bin");
try {
for (int i = 0; i < 100; i++) {
WebApp.initialize();
Date d = new Date();
BufferedImage bi = WebApp.capture(new WebAppModel("<html><h1>test</h1></html>", true, 8.5, 11, true, 2));
long duration = new Date().getTime() - d.getTime();
System.out.println("#### NEW: " + bi.getWidth() + "x" + bi.getHeight() + " " + duration + "ms");
/*LegacyWebApp.initialize();
Date d = new Date();
BufferedImage bi = LegacyWebApp.capture(new WebAppModel("<html><h1>test</h1></html>", true, 8.5, 11, true, 2));
long duration = new Date().getTime() - d.getTime();
System.out.println("#### OLD: " + bi.getWidth() + "x" + bi.getHeight() + " " + duration + "ms");*/
}
} catch(Throwable e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment