/* Test rendering of characters and sequences according to DIN 91379 with OPEN HTML TO PDF * See https://github.com/danfickle/openhtmltopdf */ import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import com.openhtmltopdf.pdfboxout.PdfRendererBuilder; public class Test1 { public static void main(String[] args) throws Exception { if (args.length != 2) { System.out.println("USAGE: Test1 inputdir outputdir"); return; } String dir = args[0]; String outdir = args[1]; String sansFontname = dir + "/" + "NotoSans-Regular.ttf"; String sansmathFontname = dir + "/" + "NotoSansMath-Regular.ttf"; work(dir + "/" + "Din91379-Letters.html", outdir, sansFontname, sansmathFontname); work(dir + "/" + "Din91379-List.html", "u:/tmp", sansFontname, sansmathFontname); System.out.println("Done."); } public static void work(String htmlFilename, String outputDir, String sansFontname, String sansmathFontname) { File htmlFile = new File(htmlFilename); try (OutputStream os = new FileOutputStream(outputDir + "/" + htmlFile.getName() + ".pdf")) { PdfRendererBuilder builder = new PdfRendererBuilder(); builder.useFont(new File(sansFontname), "notosans"); builder.useFont(new File(sansmathFontname), "notosansmath"); builder.withFile(htmlFile); builder.toStream(os); builder.run(); } catch (Exception e) { e.printStackTrace(); } } }