Skip to content

Instantly share code, notes, and snippets.

@ogavrisevs
Created June 7, 2012 07:06
Show Gist options
  • Save ogavrisevs/2887071 to your computer and use it in GitHub Desktop.
Save ogavrisevs/2887071 to your computer and use it in GitHub Desktop.
Create pdf using pd4ml from html (html table is unsuported )
ByteArrayInputStream inputStream = new ByteArrayInputStream(htmlData);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PD4ML pd4ml = new PD4ML();
pd4ml.enableDebugInfo();
try {
pd4ml.setPageSize( PD4Constants.A4 );
pd4ml.setPageInsetsMM( new Insets(topValue, leftValue, bottomValue, rightValue) );
pd4ml.useTTF("path/registration/report", true);
pd4ml.setHtmlWidth(userSpaceWidth);
pd4ml.render( inputStreamReader, outputStream );
}catch (Exception e ){
e.printStackTrace();
}
return outputStream.toByteArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment