Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JWord
>
Tutorial
> Set font
The following example shows you how to set Run's font (text font).
import com.independentsoft.office.word.Paragraph; import com.independentsoft.office.word.Run; import com.independentsoft.office.word.WordDocument; public class Example { public static void main(String[] args) { try { WordDocument doc = new WordDocument(); Run run = new Run(); run.addText("Hello Word."); run.setAsciiFont("Times New Roman"); run.setHighAnsiFont("Times New Roman"); run.setFontSize(28); //14 points Paragraph paragraph = new Paragraph(); paragraph.add(run); doc.getBody().add(paragraph); doc.save("c:\\test\\output.docx", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*