Skip to content

Instantly share code, notes, and snippets.

@Se7soz
Created April 22, 2013 09:10
Show Gist options
  • Save Se7soz/5433444 to your computer and use it in GitHub Desktop.
Save Se7soz/5433444 to your computer and use it in GitHub Desktop.
IText renderer code
private void convertHtmlToPdf(File inputFile, File outputFile) throws IOException, FileNotFoundException, DocumentException {
String path = inputFile.toURI().toURL().toString();
ITextRenderer renderer = new ITextRenderer();
ITextFontResolver fr = renderer.getFontResolver();
fr.addFont(properties.getProperty("itext.fonts.lucidaFontPath"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocument(path);
renderer.layout();
OutputStream os = new FileOutputStream(outputFile);
renderer.createPDF(os);
os.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment