I'm using AutoFitWidth, but some of my text in a PDF document is getting clipped

1 Answer 72 Views
PdfProcessing SpreadProcessing
Christopher
Top achievements
Rank 2
Iron
Iron
Christopher asked on 26 May 2023, 08:53 PM

I'm creating a spreadsheet Workbook, then exporting it to PDF. Each cell I write has a custom style where the FontSize is being set to 9 (and I'm also setting up fills and font effects, like bold).

When I get through writing the data to the Worksheet(s) in the Workbook, I then call AutoFitWidth on the Columns that have data.

Finally, I use the PdfFormatProvider to write the entire Workbook to a PDF file.

My problem is that text items in the cells are being clipped, even when there is room to fit them after calling AutoFitWidth.

For example:

It seems to be worse on strings with all caps. Sometimes it's just half a letter, other times it's multiple letters (the ATMOSPHERICCORR is supposed to be ATMOSPHERICCORROSION).

Here's another export in a different format:

As you can see, there's two problems based on calculating the required width. First is that AutoFitWidth is not giving enough space (mostly in the second example), but as you can see in the first example, even when there is enough horizontal space, it's still clipping off the text area within the cell.

Is the estimation assuming no caps, or is the font size/font family throwing it off (9pt)? Or am I missing something where I can force it to make more space?

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimitar
Telerik team
answered on 29 May 2023, 08:13 AM

Hello Christopher,

Which version of .Net are you using? If you are using the Net Standart version you need to change the default text measurer. Detailed information is available here: SpreadProcessing - Text Measuring - Telerik Document Processing

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Christopher
Top achievements
Rank 2
Iron
Iron
commented on 30 May 2023, 01:47 PM

That was it. 

Adding:

SpreadExtensibilityManager.TextMeasurer = new SpreadFixedTextMeasurer();

Fixed the problem

Tags
PdfProcessing SpreadProcessing
Asked by
Christopher
Top achievements
Rank 2
Iron
Iron
Answers by
Dimitar
Telerik team
Share this question
or