Why an empty line at the beginning of the document?

Hi

I just create an empty 'Aspose.Words.Document'.

Then I create a 'Aspose.Words.Paragraph' and add to it a 'Aspose.Words.Run' object with a sample text.

I add the 'Paragraph' to the document with this code: 'asposeDocument.FirstSection.Body.AppendChild( ... )'

When I open then the created document the text starts from the second line !! The first line is kept empty !!

How can I avoid this behaviour ?

Thanks

David

Hi David,

This happens because a blank document already has one empty paragraph as a child of the first section's body. You can call for example

doc.FirstSection.Body.Paragraphs.Clear();

before adding your paragraph to the document.

Another way (a neater one probably) is using DocumentBuilder.Write and DocumentBuilder.Writeln to insert text into the document.