Measure Text inside of TextFragment

I am using Aspose.PDF.Document and have a table with rows and cells. I am trying to size the columns based on the largest cell content. I am having troubling finding examples or this online.

Can someone help me find out how to do this.?

Do I have to measure the strings based in .net graphics or is there a built in way?

Hi Brandon,


Thanks for your inquiry. I am afraid currently the requested feature is not supported in Aspose.Pdf.Document (DOM appraoch). We have logged an enhancement ticket as PDFNEWNET-36916 to find maximum width of column contents. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,

How can you appropriately size your tables columns based on dynamic text within your cells? You had this feature in Generators.pdf, but not in document?

This request seems like it would a must for anyone using this product? Why would someone use apose.document over generators.pdf?

Hi Brandon,


Thanks for your feedback. Aspose.Pdf.Document is based in new DOM approach and it is more efficient and improved. We are fixing the issues reported in Aspose.Pdf.Genertor in new generator along with adding features/functionalites of Aspose.Pdf.Genertor in it. We have already completed most of the work but still some work is pending and our development team is working hard to complete it as soon as possible.

Moreover, In reference to above reported issue. We do understand its importance so we had already logged the issue with high priority; We will keep you updated about the issue resolution progress via this forum thread.

We are truly sorry for the inconvenience.

Best Regards,

When will all of this be released? We are ramping up for a development cycle and need to find a tool for pdf creation.

Hi Brandon,


Thanks for your inquiry. As we have recently notice the reported issue and as soon as team will complete its analysis then we would be in a good position to share an ETA. We will keep you updated about the issue resolution progress.

Thanks for your patience and cooperation.

Best Regards,

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


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

Hi Brandon,


In reference to above stated fix. You can adjust column width as per contents using ColumnAdjustment property to auto-fit. Hopefully it will help you to accomplish the task.

string outFile = “36916.pdf”;<o:p></o:p>

// Added document

Document doc = new Document();

Page page = doc.Pages.Add();

//Create a table object and add it to the paragraphs collection of the section

Table tab1 = new Table();

page.Paragraphs.Add(tab1);

//Set the column widths and default cell border of the table

tab1.ColumnAdjustment = ColumnAdjustment.AutoFitToContent;

tab1.ColumnWidths = "50 50 50";

tab1.DefaultCellBorder = new BorderInfo(BorderSide.All, 1F);

//Prepare an array of string values to be added to table

string[] data = new string[] { "Sample Text", "8.4", "Its test to set column width as per contnents" };

//Import the contents of the array created in above step

tab1.ImportArray(data, 0, 0, true);

//save the resultant PDF

doc.Save(outFile);

Please feel free to contact us for any further assistance.


Best Regards,

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan