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

Free Support Forum - aspose.com

Need help with TextWidth property

I had a technical question.

Text taskHeader = new Text(“Tasks and History”);

Now I want the width to be occupied by taskHeader on the page.

taskHeader.TextWidth property is giving value -1.

Please suggest how Can I get the width of the text.

Hello Sanjay,

Thanks for using our products.

I have tested the scenario and have managed to notice the same issue. For further investigation, I have logged it as PDFNEWNET-30089 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for your inconvenience.

However as a workaround, you may iterate through individual segments inside Text object and get the length of contents inside each segment. please take a look over following code snippet for better understanding.


// instantiate PDF obeject
Pdf pdf = new Pdf();
// create a section object and add it to PDF
Section sec = pdf.Sections.Add();
// create a sample Text object with sample string
Text sample = new Text("Sample Text in Document");
// add a new segment to Text object
Segment segment1 = sample.Segments.Add("Another Segment");

int i = 0;
// itterate throguh all the segments inside Text object
foreach(Segment seg in sample.Segments)
// Display the legth of each segment inside text object
i += 1;
// add text to paragraphs collection of section
// save the resultant PDF

The issues you have found earlier (filed as PDFNEWNET-30089) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.