FileReader fr=new FileReader("E://HtmlToDoc//LETTER.html" );
BufferedReader br=new BufferedReader(fr);
while( (s=br.readLine())!= null ){
html=html+s;}
html="<html><body>"+html.substring(html.indexOf("<body>"));
/************************ Setting Page Size **********************************/
Docx4jProperties.getProperties().setProperty("docx4j.PageSize", "B4JIS");
String papersize= Docx4jProperties.getProperties().getProperty("docx4j.PageSize", "B4JIS");
String landscapeString = Docx4jProperties.getProperties().getProperty("docx4j.PageOrientationLandscape", "true");
boolean landscape= Boolean.parseBoolean(landscapeString);
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.valueOf(papersize), landscape);
AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/hw.html"));
afiPart.setBinaryData(html.getBytes());
//afiPart.setBinaryData(fileContent);
afiPart.setContentType(new ContentType("text/html"));
Relationship altChunkRel = wordMLPackage.getMainDocumentPart().addTargetPart(afiPart);
// .. the bit in document body
CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
ac.setId(altChunkRel.getId() );
wordMLPackage.getMainDocumentPart().addObject(ac);
// .. content type
wordMLPackage.getContentTypeManager().addDefaultContentType("html", "text/html");
wordMLPackage.save(new java.io.File("E://HtmlToDoc//" + "test.docx"));
This is my code converts from HTML to Word document. How to set font size and font family for this word document.