Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Sun Jan 26, 2014 12:03 am

I need to draw lines of varying lengths in a document. Is there a function in Spire.Doc that is like the MS Word AddLine method?

cduva
 
Posts: 3
Joined: Mon Dec 16, 2013 3:24 pm

Sun Jan 26, 2014 6:23 am

Hello cduva,

Spire.Doc doesn’t support adding lines directly to document. But you can use Table to fulfill the job. Check the code below:
Code: Select all
static void Main(string[] args)
        {
            Document document = new Document();
            Section section = document.AddSection();
            Paragraph para = section.AddParagraph();
            para.AppendText("This is a line.");

            Spire.Doc.Table table = section.AddTable();
            table.ResetCells(1, 1);

            //set the length
            PreferredWidth width=new PreferredWidth(WidthType.Percentage, 50);
            table.PreferredWidth = width;

            TableRow row = table.Rows[0];
            //romove three borders
            row.RowFormat.Borders.Top.BorderType = BorderStyle.Cleared;
            row.RowFormat.Borders.Left.BorderType = BorderStyle.Cleared;
            row.RowFormat.Borders.Right.BorderType = BorderStyle.Cleared;

            document.SaveToFile("result.doc", FileFormat.Doc);

        }

If you have any questions, welcome to tell us.

Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Sun Jan 26, 2014 6:17 pm

Thanks for the reply Benjamin.

I will see if I can use that to satisfy my requirement.

I see that the ShapeType enum contains a value for Line. Is this only used to identify objects when traversing a document?

If a line is identified in a document, can Spire manipulate it?

cduva
 
Posts: 3
Joined: Mon Dec 16, 2013 3:24 pm

Mon Jan 27, 2014 6:21 am

Hello cduva,

We are very sorry. Our Spire.Doc doesn’t support drawing shape lines at present. If the lines are shape lines in document, sorry that Spire.Doc can’t manipulate them.
If you have any questions, welcome to get it back to us.

Regards,
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Return to Spire.Doc