Problems with character/font conversion
Hi,
I'm having some trouble with fonts when printing a report to PDF using
TppPDFDevice. The problem is that if I use the Akkurat font, the
easteuropean character "C" (\u010c) is replaced with a "C", sometimes on
the customer site elso with a "È". However, the character prints
correctly in the report preview. Also, if I print the report using e.g.
Foxit Reader PDF printer, the character is displayed correctly in the
PDF. The code I'm using to print the report is:
var
lPDFDevice: TppPDFDevice;
begin
lPDFDevice.PDFSettings.EmbedFontOptions := [efAllFonts];
lPDFDevice.PDFSettings.FontEncoding := feUnicode;
lPDFDevice.Publisher := form1.report.Publisher;
form1.report.PrintToDevices;
If I check the font properties in the PDF, I get the following:
- when using Foxit Reader PDF printer: Akkurat (Embedded Subset
OpenType); Type: Type 1 (CID); Enconding: Identity-H
- when printing using the above code: Akkurat (Embedded); Type:
TrueType; Encoding: Ansi
Is there any apparent reason why this might be happening? According to
this article
http://www.digital-metaphors.com:8080/Output/PDF/PDF_Unicode_Support,
all the characters in the report should be included correctly if using a
Unicode encoding.
Thank you in advance and regards,
Jure
I'm having some trouble with fonts when printing a report to PDF using
TppPDFDevice. The problem is that if I use the Akkurat font, the
easteuropean character "C" (\u010c) is replaced with a "C", sometimes on
the customer site elso with a "È". However, the character prints
correctly in the report preview. Also, if I print the report using e.g.
Foxit Reader PDF printer, the character is displayed correctly in the
PDF. The code I'm using to print the report is:
var
lPDFDevice: TppPDFDevice;
begin
lPDFDevice.PDFSettings.EmbedFontOptions := [efAllFonts];
lPDFDevice.PDFSettings.FontEncoding := feUnicode;
lPDFDevice.Publisher := form1.report.Publisher;
form1.report.PrintToDevices;
If I check the font properties in the PDF, I get the following:
- when using Foxit Reader PDF printer: Akkurat (Embedded Subset
OpenType); Type: Type 1 (CID); Enconding: Identity-H
- when printing using the above code: Akkurat (Embedded); Type:
TrueType; Encoding: Ansi
Is there any apparent reason why this might be happening? According to
this article
http://www.digital-metaphors.com:8080/Output/PDF/PDF_Unicode_Support,
all the characters in the report should be included correctly if using a
Unicode encoding.
Thank you in advance and regards,
Jure
This discussion has been closed.
Comments
It does not appear your font is being exported with Unicode encoding.
Are you loading templates? If so, you need to be sure to set the PDF
settings after the template is loaded.
As a test I tried your code below with a minimal application and it
correctly exported the Arial font in Unicode encoding. I suggest
creating a similar minimal example and trying to recreate this behavior.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
you're right, the report is loaded from a template. However, I
reproduced the issue even without using templates. The code I used is
this (probably it isn't of much use without having the definition of the
report and the fonts, but I'll post it anyway):
procedure TForm1.Button1Click(Sender: TObject);
begin
lPDFDevice := TppPDFDevice.Create(nil);
lPDFDevice.PDFSettings.OpenPDFFile := false;
lPDFDevice.PDFSettings.EmbedFontOptions := [efAllFonts];
lPDFDevice.PDFSettings.FontEncoding := feUnicode;
lPDFDevice.FileName := 'c:\temp\test1.pdf';
lPDFDevice.Publisher := ppreport1.Publisher;
ppreport1.PrintToDevices;
lPDFDevice.Free;
end;
I also noticed something very strange. If I generate a pdf using the
above code on my development machine where the Akkurat font is
installed, the problem reproduces. However, if I take the same compiled
application and transfer it to a machine which doesn't have Akkurat
fonts installed and generate the PDF, the problem doesn't reproduce -
the font gets encoded as Identitiy-H and it doesn't seem that a
substitute font is used instead, so I'm wondering how can a PDF have
embedded fonts if they are not present on the system where the PDF is
generated....and of top of that the problematic character "C" is also
displayed correctly.
If you like, I can send you the source of the sample application I used
to reproduce the issue, the fonts and the two PDFs I generated.
Thank you and regards,
Jure
Which version of ReportBuilder and Delphi are you using? I copy/pasted
your code into a buttonclick event on my machine and all fonts were
exported as Unicode fonts.
Does this only occur with the Akkurat font?
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I have:
Delphi XE5 with Update 2 installed
ReportBuilder Enterprise Edition, Version 15.04 Build 145
Yes, actually it seems that only this font causes problems. If I use
e.g. the Courier New font with the sample code I provided in the
previous post, all characters display correctly, though the encoding of
the Courier New font is Identitiy-H.
Regards,
Jure
support@digital-metaphors.com in .zip format and I'll take a look at it
for you. It may be that the Akkurat font does not support the
characters you need or it is not a valid TrueType font.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
In this case it will be exported as Type: TrueType; Encoding: Ansi in any
case!!!
On Wed, 28 Jan 2015 18:28:11 +0300, Nico Cizik (Digital Metaphors)
not ReportBuilder.
ReportBuilder PDF has been tested to function correctly with all
natively installed MS Windows fonts. Any third party fonts used will
need to comply completely with these standards in order to fully function.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com