Free Support Forum - aspose.com

Comparing with Word Object library

I'm using Word automation in server (it is a pain !!) quite extensively to format Word documents. I recently downloaded the trial version of Aspose Words, it is very fast and quite impressive. However, I could not find some of the objects like Line, Selection and different variants of GoTo function (like GoTo a page).

Here are some formatting requirement that i address with Word objects now.

1. If the number of lines in last page of a document is less than a particular number (say 3), move 'n' lines from the previous page to the last page (I insert a page break before the 'n' th line in the last-but-one page to manage this)

2. If the document has more than one page, delete the blank lines and reduce the font to make the document fit one page

Can i implement the above formatting requirements with Aspose Words? If not, is there any plans to support Word objects like Line, Selection and also an extenive GoTo function list that Word objects offer.?

Hi

Thanks for your interest in ASpose products. Unfortunately, Aspose.Words does not have MoveToPage method and MoveToLine, also you can’t determine how many lines page contains. This feature is called pagination and it is not released yet. Also see FAQ for more information.

Best regards.

Thanks, i tried to find the line break character with the ReplacementAction. It returns an exception as documented in the help file. Can i expect this feature to be available in future release? If so i can use this to calculate the page count, line count etc in the document.

what about the numbered list support? Any development on the numbered list support?

Hi

Thanks fro your request.

1) You can try to convert your document to text and then find line breaks.

string test = doc1.Range.Text;

LineBreak char = “\v”

ParagraphBreak char = “\r”

PageBreak char = “\f”

2) Numbered list is supported by Aspose.Words. See the following link.
http://www.aspose.com/Products/Aspose.Words/Api/ListFormatting.html

Also see the following code.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.ListFormat.ApplyNumberDefault();

builder.Writeln("Item 1");

builder.Writeln("Item 2");

builder.Writeln("Item 3");

builder.ListFormat.RemoveNumbers();

doc.Save(@"368_103002_prasanth.skumar\out.doc");

Please let me know if you would like to know something else.

Best regards.

Regarding the naviagtion through line breaks and page breaks, i think text conversion will not server my purpose. My requirement is to insert some text at the start of certain lines in a page (preserving the formatting of the text). In other words, i need to go to the start of the line, insert some text and save that back to the document.

This is one feature we badly need for our formatting purpose. Can you help me with this?

Also, can i request this as a new feature in Aspose Word (if not available now)

regards

Prasanth

Hi

Thank you for additional information. Aspose.Words document represents content and formatting of a document, not its layout into pages and lines.

If you would like to insert some text at the beginning of some paragraph then you can use code like the following.

Document doc = new Document("in.doc");

//paragraph index

int parIndex = 2;

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToParagraph(parIndex, 0);

builder.Write("Some text at the begining of the paragraph.");

doc.Save("out.doc");

I hope that this will help you.

Best regards.

Hi Prasanth,

There is no way you can get access to individual lines or pages in Aspose.Words.