HtmlToWorldBuilder.java: In method "parseProperties()" set default run fontSize to 11 & added cases for headers H1-H6 & if alignment is JUSTIFY set alignment to "both".
This commit is contained in:
parent
180ca8c378
commit
c540e3e312
|
@ -75,6 +75,7 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
|
||||
private void parseProperties(Node node) {
|
||||
properties.entrySet().forEach(stringBooleanEntry -> {
|
||||
this.run.setFontSize(11);
|
||||
switch (stringBooleanEntry.getKey()) {
|
||||
case "i" :
|
||||
case "em":
|
||||
|
@ -121,6 +122,9 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
if (stringBooleanEntry.getValue()) {
|
||||
if (node.hasAttr("align")) {
|
||||
String alignment = node.attr("align");
|
||||
if(alignment.toUpperCase(Locale.ROOT).equals("JUSTIFY")) {
|
||||
alignment = "both";
|
||||
}
|
||||
this.paragraph.setAlignment(ParagraphAlignment.valueOf(alignment.toUpperCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
|
@ -213,6 +217,28 @@ public class HtmlToWorldBuilder implements NodeVisitor {
|
|||
this.run.addBreak();
|
||||
}
|
||||
break;
|
||||
case "h1":
|
||||
System.out.println(this.run.getFontSize());
|
||||
this.run.setFontSize(24);
|
||||
break;
|
||||
case "h2":
|
||||
this.run.setFontSize(20);
|
||||
break;
|
||||
case "h3":
|
||||
this.run.setFontSize(16);
|
||||
break;
|
||||
case "h4":
|
||||
this.run.setFontSize(14);
|
||||
this.run.setBold(stringBooleanEntry.getValue());
|
||||
break;
|
||||
case "h5":
|
||||
this.run.setFontSize(14);
|
||||
break;
|
||||
case "h6":
|
||||
this.run.setFontSize(11);
|
||||
this.run.setBold(stringBooleanEntry.getValue());
|
||||
this.run.setCapitalized(stringBooleanEntry.getValue());
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue