We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Specify Font Formatting on the Paragraph Mark Hidden Characters of Word Document using C# .NET API

Hello,
Regular paragraphs are fine but I have issues with empty text. Do you have any workaround ?

I am getting “Times New Roman” instead of “Verdana” as the result of this test:

@Test
  public void emptyParagraph() throws Exception {
    License license = new License();
    license.setLicense(this.getClass().getResourceAsStream("/Aspose.Total.Java.lic"));
    com.aspose.words.Document document = new com.aspose.words.Document();
    document.getFirstSection().getBody().removeAllChildren();
    com.aspose.words.Paragraph paragraph = new com.aspose.words.Paragraph(document);
    Run text = new Run(document);
    text.getFont().setName("Verdana");
    text.setText("");
    paragraph.appendChild(text);
    document.getFirstSection().getBody().appendChild(paragraph);
    document.save("emptyParagraph.docx", SaveFormat.DOCX);
  }

Aspose.Words 19.9.

@jbaliuka,

For empty paragraphs, you can specify font formatting on the paragraph mark character by using the following Aspose.Words for Java code:

com.aspose.words.Document document = new com.aspose.words.Document();
document.getFirstSection().getBody().removeAllChildren();
com.aspose.words.Paragraph paragraph = new com.aspose.words.Paragraph(document);
paragraph.getParagraphBreakFont().setName("Verdana");
Run text = new Run(document);
text.getFont().setName("Verdana");
text.setText("");
paragraph.appendChild(text);
document.getFirstSection().getBody().appendChild(paragraph);
document.save("E:\\temp\\emptyParagraph.docx", SaveFormat.DOCX);
1 Like