I am trying to update the “Normal” style in a new document. However an exception is thrown “Cannot add a style because a style with the same name already exists”. What am I doing wrong?
Document doc = new Document();
doc.removeAllChildren();
StyleCollection styles = doc.getStyles();
Style style = styles.get("Normal");
if (style == null)
style = styles.add(StyleType.PARAGRAPH, "Normal");
style.getFont().setSize(10);
style.getFont().setName("Helvetica");
style.getParagraphFormat().setSpaceAfter(10);
Thanks!