Free Support Forum - aspose.com

ParagraphFormat.LeftIndent not working

All logic and prior posts tell me this code should work, but I’ve spent the last 2 days trying and it doesn’t. Please help.

I’m opening an existing Word document with nothing but a header and footer and I need to write the contents of a datatable to the document. Everything works, except it does not respond to the formatting commands I’m sending – font changes and indenting.

I’m using the evaluation copy. Here is a snippet of my code.


Dim doc As Document = New Document(gAppPath + “\mydoc.doc”)

Dim docbuild As New DocumentBuilder(doc)

strFile = “textfl” & gUserID & “.doc”

docbuild.ParagraphFormat.ClearFormatting()

docbuild.Font.Size = 8

docbuild.Font.Name = “Arial”

Dim mcounter As Integer

For mcounter = 0 To max - 1

If InStr(“6,7,8,9”, Trim(dtPrint.Rows(mcounter).Item(“Number”).ToString)) > 0 Then

docbuild.ParagraphFormat.ClearFormatting()

docbuild.ParagraphFormat.LeftIndent = 100

End If

docbuild.Write(dtPrint.Rows(mcounter).Item(“PARAGRAPH”).ToString)

docbuild.ParagraphFormat.ClearFormatting()

Next

If I understand correctly what result you need to achieve, simply rewrite your code as follows:


Dim doc As Document = New Document(gAppPath + "\\mydoc.doc")

Dim docbuild As New DocumentBuilder(doc)

strFile = "textfl" & gUserID & ".doc"

docbuild.Font.Size = 8

docbuild.Font.Name = "Arial"

Dim mcounter As Integer

For mcounter = 0 To max - 1

If InStr("6,7,8,9", Trim(dtPrint.Rows(mcounter).Item("Number").ToString)) > 0 Then

docbuild.ParagraphFormat.LeftIndent = 100

Else

docbuild.ParagraphFormat.LeftIndent = 0

End If

docbuild.Write(dtPrint.Rows(mcounter).Item("PARAGRAPH").ToString)

docbuild.InsertParagraph()

Next




It’s not working. I went so far as to alter your DocumentBuilderdemo. I worked on the section that prints "This fragment demonstrates use of paragraph formatting to specify…"

I commented out the paragraphcenter line, rebuilt the project and ran the demo. It does not indent. Try it.

Please make sure that you use the latest version of Aspose.Word. I have done exactly as you describe and it works just perfectly. Paragraph containing “This fragment demonstrates use of paragraph formatting…” is still indented 2 inches from the left.

Everything is up to date. I had someone else try it and she received the same results I did. When I save it as a Word document the formatting is removed. When I save it as a PDF, it works.

If it matters we use Word 2000 SP3.

Okay, please check back in 2-3 days.

Fixed in Aspose.Word 2.2.4, for more info please see http://aspose.com/blogs/Roman.Korchagin/archive/2005/03/14/592.aspx