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

Free Support Forum - aspose.com

Add Text to a rectangle inside a Table Cell

I have an Aspose.Pdf.Table in which cells I put an Rectangle like this (simplified version):

Dim table As New Table
Dim row = table.Rows.Add()
Dim graph As Drawing.Graph = New Drawing.Graph(50, 10)
Dim rect As Drawing.Rectangle = New Drawing.Rectangle(0,0,10,10)
graph.Shapes.Add(rectLeft)
Dim dataCell = row.Cells.Add()
dataCell.Paragraphs.Add(graph)

I need to insert a Text into the Rectangle, but I cannot find anywhere a documentation for how to do this.

I appriciate any help.
Thanks

Hi there,


Thanks for your inquriy. You can use FloatingBox to add text on some absolute position and set it border property for the purpose. Please check following code snippet for the purpose. However it does not provide the solution then please share some more details about your requirement with sample intended PDF document, so we will look into it and will guide you accordingly.

Dim table As New Aspose.Pdf.Table()<o:p></o:p>

Dim row As Aspose.Pdf.Row = table.Rows.Add()

Dim fBox As New Aspose.Pdf.FloatingBox(50, 10)

fBox.Border = New Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Box, Aspose.Pdf.Color.Black)

Dim text As New TextFragment("Test")

text.Position = New Position(1, 1)

fBox.Paragraphs.Add(text)

Dim dataCell As Aspose.Pdf.Cell = row.Cells.Add()

dataCell.Paragraphs.Add(fBox)

Please feel free to contact us for any further assistance.

Best Regards,

Thank you for your answer.

My problem is to visualize small diagramms like this ones:

-20% |__95%
-80% |75%_

The diagramm work fine with the following simplified code:

Dim graph As Drawing.Graph = New Drawing.Graph(102, 10)
Dim rectLeft As Drawing.Rectangle = New Drawing.Rectangle(40, 0, 10, 10)
Dim rectMiddle As Drawing.Rectangle = New Drawing.Rectangle(51, 0, 0, 10)
Dim rectRight As Drawing.Rectangle = New Drawing.Rectangle(52, 0, 45, 10)

graph.Shapes.Add(rectLeft)
graph.Shapes.Add(rectMiddle)
graph.Shapes.Add(rectRight)

Dim dataCell = row.Cells.Add()
dataCell.Paragraphs.Add(graph)

But to put the text inside the Rectangle I’m not able to do.
The solution with the FloatingBox will not allow me to position the items relatively to the parent cell to achieve percentual diagramms.

Do you have a solution for my problem?
Thank you so much for your help.

Hi there,


Thanks for sharing additional information. After initial investigation, I have logged an enhancement ticket PDFNEWNET-40707 in our issue tracking system for further investigation and rectification. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

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


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