Tilal Ahmad Sana November 18, 2016one Comment

Get Text Width Dynamically in Aspose.Pdf for .NET 16.11.0

Get Text Width Dynamically in Aspose.Pdf for .NET 16.11.0

November 18, 2016
Share on FacebookTweet about this on TwitterShare on LinkedIn

We are pleased to announce the release of Aspose.Pdf for .NET 16.11.0. This release includes number of improvements along with a new feature to get text width dynamically. We have received number of requests to provide some functionality to get text width dynamically in public API, and we have implemented this feature in current release. We have improved PDF to PDFA conversion, PDF to DOC/DOCX conversion along with many other bug fixes, reported in earlier releases, that improved the quality of Aspose.Pdf for .NET API to make it more stable. Please check the detailed release notes of Aspose.Pdf for .NET 16.11.0, in order to get an idea about the new features and improvements made in this release of Aspose.Pdf for .NET.

Please note If you are planning to upgrade the API from any previous version, we strongly recommend you to check the Public API Changes Section of other intermediate releases from release notes pages, to know what has been changed since your current revision of the API.

 

The following sections describe some details regarding these newly added features/enhancements.

Features

Text width dynamically: With release of this version, now we can get text width dynamically with use of MeasureString() mthod. We can invoke MeasureString() method of Aspose.Pdf.Text.Font or Aspose.Pdf.Text.TextState classes (or both):

Aspose.Pdf.Text.Font font = FontRepository.FindFont("Arial");

Console.WriteLine(font.MeasureString("Sample text", 14));

TextState ts = new TextState();

ts.Font = font;

ts.FontSize = 14;

Console.WriteLine(ts.MeasureString("Sample text"));

for (char c = 'A'; c <= 'z'; c++)

{

double fnMeasure = font.MeasureString(c.ToString(), 14);

double tsMeasure = ts.MeasureString(c.ToString());

Console.WriteLine(String.Format("{0} - font measure {1}", c, fnMeasure));

Console.WriteLine(String.Format("{0} - text state measure {1}", c, tsMeasure));

}

Text Searching : We have improved text searching procedure. From Aspose.Pdf 16.10 TextFragmentAbsorber returns text under rectangle more accurate. The rectangle may be specified with TextFragmentAbsorber.TextSearchOptions.Rectangle property.

....

//create TextAbsorber object to find all instances of the input search phrase

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();

textFragmentAbsorber.TextSearchOptions.LimitToPageBounds = true;

textFragmentAbsorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(100, 700, 195, 650);

//accept the absorber for all the pages

document.Pages.Accept(textFragmentAbsorber);

....

Improvements

PDF to PDFA conversion: This feature is very much improved in this release, as we have fixed number of PDFA related issues in Aspose.Pdf for .NET 16.11.0.

PDF to DOC/DOCX: PDF to DOC/DOCX conversion is key feature of our API. We have resolved some issues in this release that enhanced the feature reliability.

In addition to above stated improvements, this version also includes some other important bug fixes as well. There have been specific improvements regarding HTML to PDF, PDF to HTML, Text Replacement and  PDF to XPS. Please check release notes of Aspose.Pdf for .NET 16.11.0 for complete list of bug fixed.

Aspose.Pdf for .NET Resources

The following resources will help you work with Aspose.Pdf for .NET:

Join the Conversation

1 Comment

Leave a comment

Posted inAspose.PDF Product Family
 

Related Articles