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.

Wed Nov 13, 2019 1:15 pm

I greet you.
There is a task on the coordinates of two points to draw a segment in the document. Method
ShapeObject shape = para.AppendShape ((float) (mx2-mx1), (float) (my2-my1), ShapeType.Line);
                shape.HorizontalOrigin = HorizontalOrigin.Page;
                shape.HorizontalPosition = (float) mx1;
                shape.VerticalOrigin = VerticalOrigin.Page;
                shape.VerticalPosition = (float) my1;
                shape.LineStyle = ShapeLineStyle.Single;
not quite satisfied as it fits the line into a rectangle with the base coordinate of the upper left.
Tell me how can this be done?

I did it by standard means:

                Word.Shape shape1 = doc.Shapes.AddLine ((float) sx, (float) sy, (float) ex, (float) ey, ref missing);

                shape1.Select ();
                shape1.Line.EndArrowheadStyle = headStyle;
                shape1.Line.DashStyle = lineType;
                shape1.Line.Weight = (float) Weight;
                shape1.Line.ForeColor.RGB = ColorTranslator.ToOle (color);

Thank!

LandLord75
 
Posts: 3
Joined: Tue Nov 12, 2019 2:42 pm

Thu Nov 14, 2019 9:00 am

Hi,

Thanks for your inquiry.
According to your last code, I guess you want to draw a line with arrow in Word document, right? If so, below is the code for you.

Code: Select all
            ShapeObject shape2 = para1.AppendShape(200, 5, ShapeType.Arrow);
            shape2.FillColor = Color.Purple;
            shape2.StrokeColor = Color.Black;
            shape2.LineStyle = ShapeLineStyle.ThickThin;
            shape2.StrokeWeight = 1;
            shape2.HorizontalPosition = 200;
            shape2.VerticalPosition = 200;


If I misunderstand, please offer us the following information for further investigation.
1. Your result file.
2. Your desired result file.

You could upload them here or send us(support@e-iceblue.com) via email.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Tue Nov 19, 2019 9:12 am

Hello

In short, I have an array of polygon points that need to be drawn as segments in the document. Using standard office tools, this can be done easily by transferring the start and end points of a segment to a function.

How to do the same, but through Spire.Doc?

Thanks/

LandLord75
 
Posts: 3
Joined: Tue Nov 12, 2019 2:42 pm

Tue Nov 19, 2019 10:35 am

Hi,

Thanks for your reply.
Sorry that Spire.Doc doesn't support to create a line based on two points.
Kindly note that the line Spire.Doc creates is based on the “lines” of “Shapes” in MS Word. And the position of the line is controlled by the Horizontal and Vertical position in MS Word. I have shared the related screenshots here to explain it.
Hope you could understand.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Tue Nov 19, 2019 12:59 pm

Thank you for quick answer.

But, the segment fits into the square, with the beginning at the upper left point and the end at the lower right point of the square. Moreover, the first point cannot be negative (less) than the second.
It is necessary to twist the object, and given that there are several of these and you need to link one with the other, it is not easy.
Perhaps you will add such a useful feature?

LandLord75
 
Posts: 3
Joined: Tue Nov 12, 2019 2:42 pm

Wed Nov 20, 2019 2:31 am

Hi,

Thanks for your reply.
You could set the rotation of the points to make the position of the first point be negative than the second one. Below is the code for you.
Code: Select all
            ShapeObject shape2 = para1.AppendShape(200, 5, ShapeType.Line);
            shape2.HorizontalPosition = 200;
            shape2.VerticalPosition = 200;
            shape2.Rotation = 130;


Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Thu Dec 26, 2019 10:41 am

Hi,

Greetings from E-iceblue.
How's your issue doing? Could you please give us some feedback at your convenience?

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Return to Spire.Doc