We are having an issue with Shape.CalculateTextSize. Sometimes CalculateTextSize() leads a server crash. With the following code it can be reproduced.
Please use the original Japanese text.
I would appreciate If you could advice me how to avoid a crash programmatically without changing textbox sizes or text contents.
It seems that you are experiencing a server crash when using the CalculateTextSize() method with Japanese text in Aspose.Cells. This issue has been acknowledged, and it has been logged for further investigation. Specifically, it relates to the calculation of text height for long text in Japanese and other languages, which may not be handled properly in certain cases.
To avoid crashes programmatically without changing the textbox sizes or text contents, consider the following suggestions:
Font Selection: Ensure that you are using a font that supports Japanese characters. The default font, such as ‘Calibri’, may not be suitable. It is recommended to use a Japanese font like ‘MS Gothic’ or any other font that is specifically designed for Japanese text. This can help in accurately calculating the text size without causing crashes.
Here’s how you can set the font:
textbox0.Font.Name = "MS Gothic"; // Set to a Japanese font
Error Handling: Implement error handling around the CalculateTextSize() method to catch any exceptions that may arise. This way, if a crash occurs, you can handle it gracefully without affecting the entire application.
Example:
try
{
var sizes = textbox0.CalculateTextSize();
}
catch (Exception ex)
{
// Log the exception or handle it accordingly
Console.WriteLine("An error occurred: " + ex.Message);
}
Text Length Management: If possible, consider limiting the length of the text being processed. Extremely long strings may lead to issues, so you might want to implement a check before calling CalculateTextSize().
By following these suggestions, you may be able to mitigate the issue until a fix is provided by the Aspose team.
If you continue to experience problems, please keep an eye on updates regarding the logged issue for any fixes or workarounds that may be released in future versions.
After initial testing, I am able to reproduce the issue as you mentioned by using your sample code snippet. I found Shape.CalculateTextSize takes long time or causes server crash.
We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-57837
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@AT1
Your issue (CELLSNET-57837) has been resolved and the fix will be released with version 25.3.
The purpose of TextBox.CalculateTextSize() is to get a rectangle that is suitable for enclosing text so that users can resize the text box. To get the correct result, you need to take into account different languages, punctuation, and text wrapping rules. In the process of collecting and processing this information, there will inevitably be some situations that are not considered. We will continue to optimize this function in the future. If you encounter any problems when using this function, please contact us and we will focus on the problems caused by calling this function.
If you want to fully display the text content without changing the size of the text box. You can only set it as follows:
The issues you have found earlier (filed as CELLSNET-57837) have been fixed in this update. This message was posted using Bugs notification tool by leoluo
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.