#1 2025-02-07 17:24:44

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 139

Differences with PDF generation on different computers

Hi,

I'm trying to solve one of these "it works on my machine" issues, a PDF is generated and displayed correctly on my computer, while on the end user's computer it doesn't, everything was ok until their hard drive crashed and they retrieved a backup from their server, I don't know how it could affect the generation of PDFs, I'm on Windows 10, and the user has Hyper-V Server 2019.

On their side in the generated PDFs the font size looks bigger (taller and wider), and it seems that only half of the vertical space on the page is used and that causes a lot of problems because I'm drawing a table crowded with a lot of data on each page. I can't share files because of the sensitive nature of the data.

In one branch, I decided to use the AddTrueTypeFont function thinking that it could be a problem of unavailable fonts and that with this function I can include them, before sending anything to the client I thought about checking that everything is in order, AddTrueType seems to always return False, I tried with:

AddTrueType('Arial')

Which exists in my system, digging in the code I see that FastFindPUtf8CharSorted returns -1 even though Arial is in the font list, when it reaches the last line: Result := -1 result has a value of 4 which is substituted in that last line.

About this last thing, I want to know if:

1. AddTrueType is used to include fonts in the generated PDF
2. AddTrueType, does it work?

mORMot 2.3.9263, delphi 10.3

I'm running out of ideas, maybe I'm not looking in the right place, if anyone has any tips on how to fix this they are welcome.

Regards

Offline

#2 2025-02-07 17:50:21

rvk
Member
Registered: 2022-04-14
Posts: 123

Re: Differences with PDF generation on different computers

Did you embed the used fonts?
(See ctrl+d in Adobe and then fonts tab)

Offline

#3 2025-02-07 18:54:58

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 139

Re: Differences with PDF generation on different computers

Thanks RVK, I don't use Acrobat, I don't have it installed on any computer, as if today I'm being pursued by bad luck, I lost Internet service from my ISP right now, I'm using my cell phone data, maybe later I'll have access to a computer with Acrobat.

With your question, I went back to the code, you mean add a line like:

PDF.EmbeddedTtf := True;

I don't have it but I can do that

Offline

#4 2025-02-07 19:06:08

rvk
Member
Registered: 2022-04-14
Posts: 123

Re: Differences with PDF generation on different computers

moctes wrote:

PDF.EmbeddedTtf := True;
I don't have it but I can do that

Yes, not sure what fonts you used but if it's not one of the few which are default on all systems, it's best to embed the fonts.

pdf.EmbeddedTTF := true;
pdf.EmbeddedTTFIgnore.Text := RawUTF8('Arial'#13#10'Times New Roman'#13#10'Courier New'#13#10'Symbol'#13#10'WingDings');;
pdf.EmbeddedWholeTTF := false; // I use this so not the whole font-data is included

The EmbeddedTTFIgnore are the fonts which are usually on all systems.
For Windows the list is a bit bigger (see MSWINDOWS_DEFAULT_FONTS in the source) but I only used these.

(BTW. I meant Adobe reader as reader, not Adobe full suite.)

Last edited by rvk (2025-02-07 19:07:27)

Offline

#5 2025-02-10 16:24:51

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 139

Re: Differences with PDF generation on different computers

Sorry for the delay in answering, thanks for your advice, I will implement it although the problem seems to have come from somewhere else, my client had to restart his computer due to operating system updates and after the restart everything went back to normal, the PDF is generated correctly again.

(BTW. I meant Adobe reader as reader, not Adobe full suite.)

I don't use any Adobe products, for the reader, all browsers have support to view PDF files and in cases where I need a PDF reader ( on Windows ) I use Sumatra reader which is the lightest PDF reading software I could find

Offline

#6 2025-02-10 16:32:19

rvk
Member
Registered: 2022-04-14
Posts: 123

Re: Differences with PDF generation on different computers

moctes wrote:

Sorry for the delay in answering, thanks for your advice, I will implement it although the problem seems to have come from somewhere else, my client had to restart his computer due to operating system updates and after the

(BTW. I meant Adobe reader as reader, not Adobe full suite.)

I don't use any Adobe products, for the reader, all browsers have support to view PDF files and in cases where I need a PDF reader ( on Windows ) I use Sumatra reader which is the lightest PDF reading software I could find

In Sumatra reader you can press CTRL+D for properties (or use the menu) and then use "Get Fonts Info". There you can see which fonts are used and which are embedded.

It's advisable to always embed the fonts (at least a subset of the fonts) that are not default on all systems.
Calibri is widely used but there are some systems that don't have them.

(Maybe not a problem for you at the moment, if you know what fonts are on the systems, but you should keep it in mind wink )

moctes wrote:

Sorry for the delay in answering, thanks for your advice, I will implement it although the problem seems to have come from somewhere else, my client had to restart his computer due to operating system updates and after the restart everything went back to normal, the PDF is generated correctly again.

Glad to hear it was just a glitch in the system and all it took was a restart.

Offline

#7 2025-02-10 22:39:10

moctes
Member
From: Mexico
Registered: 2013-05-11
Posts: 139

Re: Differences with PDF generation on different computers

Glad to hear it was just a glitch in the system and all it took was a restart.

Yeah, I should have asked them to do it, isn't it always the quintessential solution? lol

Thank you for taking the time to help

Offline

Board footer

Powered by FluxBB