Web app - PDF wrap text different after server upgrade

I noticed after the server upgrade yesterday that the wrap text in a PDFdocument is different now. It does not seem to span the width and follow the parameter for width

This is the correct wrapping before the server upgrade:

This is the new incorrect wrapping after the server upgrade:

This is the code used:

g.DrawText(mockMessage, 15, yCoord, g.Width - 30)

I guess you want help to fix this (same for your other post).

What server? What version? Do you know what was upgraded?

1 Like

Hi Alberto, yes seeking help, thanks!

Sorry for the vagueness. This is on Xojo Cloud. Xojo version 2024 R1. Below is the email notification from Alyssa on 8/12 regarding the upgrade

On August 26th and 27th we will be upgrading all Xojo Cloud servers from CentOS 7 to AlmaLinux 9. In order to complete this upgrade, each Xojo Cloud server will experience a 1-2 hour period of downtime on August 26th or August 27th.

  • If you would like to schedule a specific window of time for this upgrade, please reply to this email before Thursday, August 22nd. We are happy to work with you to arrange a specific date and time that won’t interrupt your use of the server.

  • If we do not hear from you by Thursday, August 22nd, we will proceed with the upgrade on August 26th or 27th.

This upgrade allows Xojo to offer up-to-date security and improved performance for all Xojo Cloud users going forward. If you have any questions, please reply to this email for assistance.

You need to contact Xojo for help. Maybe they are aware of this or maybe not.

I can only guess:

  • different fonts installed after the upgrade (for this issue)
1 Like

I did see there were additional fonts added. Maybe that is a culprit. I do make the call in code to use g.FontName = “Arial”, and I have this font on my server. Nothing else with the document is messed up. Only the wrapping

I created a new Issue per Jason’s recommendation with an attached sample project:
https://tracker.xojo.com/xojoinc/xojo/-/issues/77199

2 Likes

I discovered my error with my FontName = “Arial”. @Greg_O and @AlbertoD assisted me in this post (What is the correct font name to use for Dejavu? - #4 by AlbertoD) to show the available font names. My Arial is actually named ArialMT. I added this in my test project, and the text wrapped appropriately

I am going to close the above Issue as this was an error on my part and not a bug

1 Like

Wait - would changing the font really cause such a dramatic change in the wrapping width of the text? I think there might still be a bug here.

From what I remember: in console apps, yes (long standing difference). Remember that this case the font is no longer on the server after update, it changed from ‘Arial’ to ‘ArialMT’

I understand, but if you switched the font to Times New Roman, how would it behave? Why wouldn’t it respect the specified wrap width?

Should behave correctly.

The font doesn’t exist, can’t calculate the correct width.

At least this is what I understand from previous Issues/posts in the forum.

Here is a response from Greg on my other post asking about the correct name to use. This function allowed me to see the names that are on the server. I had to build the test app to see the fonts on the server. Just debugging, it showed a ton more, but these were just fonts on my machine.

If you installed Times New Roman on your XC server, and that is the name of the font, you should be ok. In my case, I previously installed an Arial font. As Alberto said, prior to the upgrade, it might’ve been named “Arial”, but after the upgrade, it is named “ArialMT”. Thanks to Greg’s tip, I was able to see what the actual name was

If you don’t install any, it looks like these are the fonts that were added:
Cantarell
Cantarell
Cantarell
Cantarell
DejaVu LGC Sans Mono
DejaVu LGC Serif
DejaVu LGC Serif
DejaVu Sans
DejaVu Sans
DejaVu Sans
DejaVu Sans Mono
Source Code Pro
Source Code Pro
Source Code Pro
Source Code Pro
Source Code Pro
Source Code Pro

Isn’t Times New Roman a default font? I guess Eric (the same as me) expect Times New Roman to work without installing it on the server.

Maybe for Web it is required and we can’t use code like in desktop:

g.FontName = PDFDocument.StandardFontNames.TimesNewRoman

sorry, no experience to answer that.

Here is a screenshot my test app showing when g.FontName = “Times New Roman” (I do not have this installed on my server). It’s the same result I saw when using “Arial” (not installed as “Arial”, rather as “ArialMT”, which did produce the correct result)
Screenshot 2024-08-30 at 11.13.52 AM

Can’t you use this on Web?

g.FontName = PDFDocument.StandardFontNames.TimesNewRoman

if you can, does it make any difference?

Thank you.

I was surprised to see that as an option. I have only been doing g.FontName = “XXXX”. Here are the results:

Thank you for your tests.

Looks like it needs to be physical present to work. Too bad.

Don’t know if Xojo can do something about that as this is not expected.

Agreed. Doesn’t seem right to have it as an option as a StandardFontNames option

1 Like

OK, I can explain what’s going on here.

PDF readers are guaranteed to have those Standard (often called Core) fonts available: Helvetica, Times, etc. It’s part of the specification and allows many PDFs to be smaller because they don’t need to include those very commonly-used fonts.

However, in order to properly measure and lay out text, an application creating a PDF still needs to have access to the metrics for any font it wants to use if it wants to do anything more than the most basic text layout. Otherwise, there’s no way to know how wide each character is, and thus no way to know how to wrap lines, etc. This means having the font installed on the system where the application is running.

It is also perfectly valid to write a PDF that references a font you don’t have installed on your system. The PDF reader will search its own local resources for the font and if it cannot find it, it will use a generic substitution, usually with terrible (although possibly legible) results.

1 Like