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

Free Support Forum - aspose.com

How to insert Blank Paragraph into Document using DOM

Hi Team,

I’m using document builder to insert blank paragraph along with clear formatting after some nodes.

Above bolded code which is copying a text from first line of document (cursor pointing position) and pasted that text into document where i needed to create a insert blank paragraph.

Please share a correct solution to insert empty paragraph


Unfortunately, we were unable to reproduce the same issue on our side. The insertParagraph method showing the expected behavior, inserting a blank paragraph into the document.
Could you please share your template document and sample code you used, to reproduce the same issue at our end? We will investigate the issue and provide you information on it.

@Shyamu When you use insertParagraph method Aspose.Words inserts a paragraph break at the current cursor location, the cursor is moved to the beginning of the new paragraph. If you start writing text right after, the text will be placed in this new paragraph. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This is text placed in one paragraph");
// This line inserts a paragraph break and the cursor is placed at the beginning of the next paragraph
builder.writeln(); // You can also use insertParagraph
// Here we write some text and insert a paragraph break after it.
// The cursor is placed at the beginning of the next paragraph again
builder.writeln("This is the next paragraph");
// Now insert one more paragraph break to have an empty paragraph.
builder.writeln(); // You can also use insertParagraph
// Write some text.
builder.write("There is an empty paragraph before this paragraph.");