// for a bold text: api.addSentence(article, "this is the bold sentence", FontType.BOLD); // for a bold and italic text: api.addSentence(article, "this is the bold sentence", FontType.BOLD + FontType.ITALIC);
color
field specifies the sentence text colorbackground
field specifies the sentence background colorfontFace
field specifies the sentence font face[3]
size
field specifies the numeric size of the fontnamedSize
field specifies the named size of the font[4]
type
field specifies the type of the fontSentenceStyle
. For example to following code:SentenceStyle style = new SentenceStyle(); style.color = "red"; style.fontFace = FontFace.HELVETICA; style.namedSize = FontSize.SMALL;is equivalent to:
SentenceStyle style = SentenceStyle.createColorStyle("red").setFamily(FontFace.HELVETICA).setSize(FontSize.SMALL);To specify the style of a sentence, you can use:
DocGeneratorAPI api = new DocGeneratorAPI(); api.createModel(); api.setOutputDirectory(<the wiki directory>); // create an article XMLArticle article = api.createArticle("article1");The following example creates a bold sentence:
api.addSentence(article, "this is the bold sentence", FontType.BOLD);The following example creates a sentence with a small Helvetica font, using a red color:
SentenceStyle style = new SentenceStyle(); style.color = "red"; style.fontFace = FontFace.HELVETICA; style.namedSize = FontSize.SMALL; XMLTextStyle textStyle = api.addTextStyle(article, style); api.addSentence(textStyle, "this is the styled sentence");The following example does the same in a more straightforward way:
api.addSentence(SentenceStyle.createColorStyle("red").setFamily(FontFace.HELVETICA).setSize(FontSize.SMALL), "this is the styled sentence");
docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.