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

Free Support Forum - aspose.com

Text inside Shapes

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.

The issue is I am unable to enter the text into shapes. Can any one help on this.

Hi Kiriti,


Thanks for your inquiry. After initial investigation we have logged a ticket PDFNEWNET-40023 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Thanks for log the issue, and update me if it has any process to do it this scenario.

Hi Kiriti,


Thanks for your feedback. Sure, we will update you the ETA/ our findings as soon as we made some progress towards issue resolution.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-40023) have been fixed in Aspose.Pdf for .NET 17.1.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(2)