We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pdf Generator Line

I'm having hard time drawing a line

could u someone help me understanded the properties of Line position?

Currently i have a line in crystal reports and length is

X(left margin)= 0.000inch

Y(Top margin)= 2.250inch

Height= 10.660inch

Width= 0.040inch

Line thickness = 3.5pt.

Whats the equivalent in Aspose for creating a line?

Thanks

Asad

Hi Asad,


Thanks for using our products.

As per my understanding, you might be facing an issue while convert Inc to points because the basic unit of drawing line is point. Furthermore, in order to specify the dimensions of line object, you need to use floating array which contains the coordinates where line will be drawn. Please take a look over following code snippet to draw line with the width of 3.5f and height as 10.66 Inch.

[C#]

// instantiate PDF object<o:p></o:p>

Pdf pdf1 = new Pdf();

// add section to PDF file

Section sec1 = pdf1.Sections.Add();

Graph graph1 = new Graph(sec1, 200, 767);

sec1.Paragraphs.Add(graph1);

// draw a line starting at X=10 and Top of line is 767 (10.66Inch)

float[] posArr = new float[] { 10, 200, 10, 767 };

Line l1 = new Line(graph1, posArr);

// specify the width of line

l1.GraphInfo.LineWidth = 3.5f;

// set the color for line object

l1.GraphInfo.Color = new Aspose.Pdf.Generator.Color("Red");

graph1.Shapes.Add(l1);

// save PDF document

pdf1.Save(“c:/pdftest/LineInPdf.pdf”);



For your reference, I have also attached the resultant PDF generated over my end. For further information on unit conversion from Inch to Point, please visit Tips and Tricks

Thanks for the reply

Could u please explain what does these 4 floating values represents?

float[] posArr = new float[] { 10, 200, 10, 767 };

1st value represents x position?

2nd value?

3rd value?Width?

4th value?Height?

Thanks

Asad

<?XML:NAMESPACE PREFIX = O />

asadgh:
Could u please explain what does these 4 floating values represents?

float[] posArr = new float[] { 10, 200, 10, 767 };

Hi Asad,

Please note that the four floating values represent the coordinates of line.

  • First value represents LowerX
  • Second value represents LowerY
  • Third value represents UpperX
  • Fourth value represents UpperY

In the event of any further query, please feel free to contact.