We have a requirement where we need to put text inside shapes as shown in the Aspose PDF Shape.pdf. We were able to achieve like what is shown in Graph.pdf.
Below is the sample code that was used to generated Graph.pdf.
Document pdfDoc = new Document();
pdfDoc.PageInfo.Width = 612.0;
pdfDoc.PageInfo.Height = 792.0;
pdfDoc.PageInfo.Margin = new MarginInfo();
pdfDoc.PageInfo.Margin.Left = 72;
pdfDoc.PageInfo.Margin.Right = 72;
pdfDoc.PageInfo.Margin.Top = 72;
pdfDoc.PageInfo.Margin.Bottom = 72;
Page pdfPage = pdfDoc.Pages.Add();
pdfPage.PageInfo.Width = 612.0;
pdfPage.PageInfo.Height = 792.0;
pdfPage.PageInfo.Margin = new MarginInfo();
pdfPage.PageInfo.Margin.Left = 50;
pdfPage.PageInfo.Margin.Right = 50;
pdfPage.PageInfo.Margin.Top = 72;
pdfPage.PageInfo.Margin.Bottom = 72;
FloatingBox floatBox = new FloatingBox();
floatBox.Margin = pdfPage.PageInfo.Margin;
pdfPage.Paragraphs.Add(floatBox);
Aspose.Pdf.Drawing.Graph graph = new Aspose.Pdf.Drawing.Graph(500, 100);
floatBox.Paragraphs.Add(graph);
//1st rectangle
Aspose.Pdf.Drawing.Rectangle rect = new Aspose.Pdf.Drawing.Rectangle(0, 30, 50, 40);
rect.GraphInfo.LineWidth = 1f;
rect.GraphInfo.Color = Aspose.Pdf.Color.Black;
graph.Shapes.Add(rect);
//create circle
Aspose.Pdf.Drawing.Circle circle = new Aspose.Pdf.Drawing.Circle(125, 50, 25);
circle.GraphInfo.Color = Aspose.Pdf.Color.Black;
circle.GraphInfo.FillColor = Aspose.Pdf.Color.LightBlue;
circle.GraphInfo.LineWidth = 1f;
graph.Shapes.Add(circle);
//2nd rectangle
rect = new Aspose.Pdf.Drawing.Rectangle(200, 30, 70, 40);
rect.GraphInfo.FillColor = Aspose.Pdf.Color.LightBlue;
rect.GraphInfo.Color = Aspose.Pdf.Color.Black;
rect.GraphInfo.LineWidth = 1f;
graph.Shapes.Add(rect);
//First line object
Aspose.Pdf.Drawing.Line line1 = new Aspose.Pdf.Drawing.Line(new float[] { 50, 50, 100, 50 });
line1.GraphInfo.LineWidth = 3f;
line1.GraphInfo.Color = Aspose.Pdf.Color.Black;
graph.Shapes.Add(line1);
//Second line object
Aspose.Pdf.Drawing.Line line2 = new Aspose.Pdf.Drawing.Line(new float[] { 150, 50, 200, 50 });
//line.GraphInfo.LineWidth = 1f;
line2.GraphInfo.Color = Aspose.Pdf.Color.LightBlue;
graph.Shapes.Add(line2);
Issue description : I was able to create shapes inside Graph but couldn’t add text inside each shape.I would like to know if there is any way to achieve this.
Also while creating this sample we found that even though we had two different Line objects with different GraphInfo.LineWidth values,it takes only the first object’s value for both the Lines.