Font "Arial, Bold-WinCharSetFFFF" could not be found or created
Hello,
one of our customers has reported the following problem:
If he does a PDF export of a report, he receives the following error:
"Font "Arial,Bold-WinCharSetFFFF" could not be found or created. Some
characters will probably be displayed or printed incorrectly."
The resulting PDF file contains only dots or short lines - nothing
really readable.
I've seen this from time to time at other customers machines too. No
idea what happens though and also can't reproduce it on my end.
It happens by using Gnostice eDocEngine too, apparently - we offer both
ways for PDF export: Gnostice and RB internal functionality.
I will contact Gnostice too, but these are two different, independend
functionalities, so writing it here as well in the hope that it can be
fixed for the RB part in some way.
Here is how I'm doing it:
-----------------
function MyPDFExport(FileName: string): ShortInt;
var
lAllowPrintToFile, lShowPrintDialog, lShowCancelDialog: boolean;
lDeviceType, lTextFileName: string;
lFontListToEmbedd: TStringList;
begin
Result := -1;
lAllowPrintToFile := MyReport.AllowPrintToFile;
lShowPrintDialog := MyReport.ShowPrintDialog;
lShowCancelDialog := MyReport.ShowCancelDialog;
lDeviceType := MyReport.DeviceType;
lTextFileName := MyReport.TextFileName;
lFontListToEmbedd := TStringList.Create;
lFontListToEmbedd.Clear;
try
try
MyReport.AllowPrintToFile := true;
MyReport.ShowPrintDialog := false;
MyReport.ShowCancelDialog := false;
MyReport.DeviceType := 'PDF';
MyReport.PDFSettings.OpenPDFFile := true;
MyReport.PDFSettings.Author := 'Test';
MyReport.PDFSettings.Keywords := '';
MyReport.PDFSettings.Title := '';
MyReport.PDFSettings.Subject := '';
MyReport.PDFSettings.CompressionLevel := clDefault;
MyReport.PDFSettings.FontEncoding := feUnicode;
//MyReport.PDFSettings.SourceDPI := MyPDFSettings.PixelPerInch;
//MyReport.PDFSettings.OutputImageFormat := ifJPEG;
//MyReport.PDFSettings.ImagePixelFormat :=
MyPDFSettings.ImagePixelFormat_PDFExport;
CreateFontListToEmbed(lFontListToEmbedd);
if lFontListToEmbedd.Count > 0 then begin
MyReport.PDFSettings.EmbedFontList.Clear;
MyReport.PDFSettings.EmbedFontList.AddStrings(lFontListToEmbedd);
MyReport.PDFSettings.EmbedFontOptions := [efFontList,
efUseSubset];
end
else begin
MyReport.PDFSettings.EmbedFontOptions := [efUseSubset];
end;
MyReport.TextFileName := + 'PDF\';
if length(FileName) > 0 then begin
MyReport.TextFileName := MyReport.TextFileName +
uMyFileRoutines.CreateValidFileName(FileName);
end
else begin
MyReport.TextFileName := MyReport.TextFileName +
resNewExportDocument;
end;
MyReport.TextFileName := MyReport.TextFileName + '.pdf';
if not DirectoryExists(ExtractFilePath(MyReport.TextFileName))
then begin
ForceDirectories(ExtractFilePath(MyReport.TextFileName));
end;
if MyReport.InitializeParameters then begin
MyReport.Print;
end;
Result := 0;
except
on E: Exception do begin
uMyMessages.ShowException(Format(resPDFExportError,
[MyReport.TextFileName]), E.Message);
Result := -2;
end;
end;
finally
MyReport.AllowPrintToFile := lAllowPrintToFile;
MyReport.ShowPrintDialog := lShowPrintDialog;
MyReport.ShowCancelDialog := lShowCancelDialog;
MyReport.DeviceType := lDeviceType;
MyReport.TextFileName := lTextFileName;
FreeAndNil(lFontListToEmbedd);
end;
end;
procedure CreateFontListToEmbed(var FontListToEmbedd: TStringList);
var
lCounterPrintableSystemFonts, lCounterSelectedFonts: integer;
lListPrintableSystemFonts: TStringList;
lAddFont: boolean;
begin
if assigned(FontListToEmbedd) then begin
FontListToEmbedd.Clear;
lListPrintableSystemFonts := TStringList.Create;
try
lListPrintableSystemFonts.Clear;
// End user can define the fonts to embed within the configuration
section. They are being added only if they are not contained in the list
of printable system fonts
if MyPDFSettings.SelectedFonts.Count > 0 then begin
GetWindowsFonts(Application.MainForm.Canvas.Handle,
lListPrintableSystemFonts, False);
for lCounterPrintableSystemFonts := 0 to
lListPrintableSystemFonts.Count - 1 do begin
for lCounterSelectedFonts := 0 to
MyPDFSettings.SelectedFonts.Count - 1 do begin
lAddFont := true;
if
AnsiCompareText(MyPDFSettings.SelectedFonts.Strings[lCounterSelectedFonts],
lListPrintableSystemFonts.Strings[lCounterPrintableSystemFonts]) = 0
then begin
lAddFont := false;
Break;
end;
end;
if lAddFont then begin
FontListToEmbedd.Add(lListPrintableSystemFonts.Strings[lCounterPrintableSystemFonts]);
end;
end;
end;
finally
FreeAndNil(lListPrintableSystemFonts);
end;
end;
end;
-----------------
This works in 99% of all cases, but sometimes for some reason it fails.
Any ideas, suggestions, comments are welcome.
Best regards,
Mark
one of our customers has reported the following problem:
If he does a PDF export of a report, he receives the following error:
"Font "Arial,Bold-WinCharSetFFFF" could not be found or created. Some
characters will probably be displayed or printed incorrectly."
The resulting PDF file contains only dots or short lines - nothing
really readable.
I've seen this from time to time at other customers machines too. No
idea what happens though and also can't reproduce it on my end.
It happens by using Gnostice eDocEngine too, apparently - we offer both
ways for PDF export: Gnostice and RB internal functionality.
I will contact Gnostice too, but these are two different, independend
functionalities, so writing it here as well in the hope that it can be
fixed for the RB part in some way.
Here is how I'm doing it:
-----------------
function MyPDFExport(FileName: string): ShortInt;
var
lAllowPrintToFile, lShowPrintDialog, lShowCancelDialog: boolean;
lDeviceType, lTextFileName: string;
lFontListToEmbedd: TStringList;
begin
Result := -1;
lAllowPrintToFile := MyReport.AllowPrintToFile;
lShowPrintDialog := MyReport.ShowPrintDialog;
lShowCancelDialog := MyReport.ShowCancelDialog;
lDeviceType := MyReport.DeviceType;
lTextFileName := MyReport.TextFileName;
lFontListToEmbedd := TStringList.Create;
lFontListToEmbedd.Clear;
try
try
MyReport.AllowPrintToFile := true;
MyReport.ShowPrintDialog := false;
MyReport.ShowCancelDialog := false;
MyReport.DeviceType := 'PDF';
MyReport.PDFSettings.OpenPDFFile := true;
MyReport.PDFSettings.Author := 'Test';
MyReport.PDFSettings.Keywords := '';
MyReport.PDFSettings.Title := '';
MyReport.PDFSettings.Subject := '';
MyReport.PDFSettings.CompressionLevel := clDefault;
MyReport.PDFSettings.FontEncoding := feUnicode;
//MyReport.PDFSettings.SourceDPI := MyPDFSettings.PixelPerInch;
//MyReport.PDFSettings.OutputImageFormat := ifJPEG;
//MyReport.PDFSettings.ImagePixelFormat :=
MyPDFSettings.ImagePixelFormat_PDFExport;
CreateFontListToEmbed(lFontListToEmbedd);
if lFontListToEmbedd.Count > 0 then begin
MyReport.PDFSettings.EmbedFontList.Clear;
MyReport.PDFSettings.EmbedFontList.AddStrings(lFontListToEmbedd);
MyReport.PDFSettings.EmbedFontOptions := [efFontList,
efUseSubset];
end
else begin
MyReport.PDFSettings.EmbedFontOptions := [efUseSubset];
end;
MyReport.TextFileName := + 'PDF\';
if length(FileName) > 0 then begin
MyReport.TextFileName := MyReport.TextFileName +
uMyFileRoutines.CreateValidFileName(FileName);
end
else begin
MyReport.TextFileName := MyReport.TextFileName +
resNewExportDocument;
end;
MyReport.TextFileName := MyReport.TextFileName + '.pdf';
if not DirectoryExists(ExtractFilePath(MyReport.TextFileName))
then begin
ForceDirectories(ExtractFilePath(MyReport.TextFileName));
end;
if MyReport.InitializeParameters then begin
MyReport.Print;
end;
Result := 0;
except
on E: Exception do begin
uMyMessages.ShowException(Format(resPDFExportError,
[MyReport.TextFileName]), E.Message);
Result := -2;
end;
end;
finally
MyReport.AllowPrintToFile := lAllowPrintToFile;
MyReport.ShowPrintDialog := lShowPrintDialog;
MyReport.ShowCancelDialog := lShowCancelDialog;
MyReport.DeviceType := lDeviceType;
MyReport.TextFileName := lTextFileName;
FreeAndNil(lFontListToEmbedd);
end;
end;
procedure CreateFontListToEmbed(var FontListToEmbedd: TStringList);
var
lCounterPrintableSystemFonts, lCounterSelectedFonts: integer;
lListPrintableSystemFonts: TStringList;
lAddFont: boolean;
begin
if assigned(FontListToEmbedd) then begin
FontListToEmbedd.Clear;
lListPrintableSystemFonts := TStringList.Create;
try
lListPrintableSystemFonts.Clear;
// End user can define the fonts to embed within the configuration
section. They are being added only if they are not contained in the list
of printable system fonts
if MyPDFSettings.SelectedFonts.Count > 0 then begin
GetWindowsFonts(Application.MainForm.Canvas.Handle,
lListPrintableSystemFonts, False);
for lCounterPrintableSystemFonts := 0 to
lListPrintableSystemFonts.Count - 1 do begin
for lCounterSelectedFonts := 0 to
MyPDFSettings.SelectedFonts.Count - 1 do begin
lAddFont := true;
if
AnsiCompareText(MyPDFSettings.SelectedFonts.Strings[lCounterSelectedFonts],
lListPrintableSystemFonts.Strings[lCounterPrintableSystemFonts]) = 0
then begin
lAddFont := false;
Break;
end;
end;
if lAddFont then begin
FontListToEmbedd.Add(lListPrintableSystemFonts.Strings[lCounterPrintableSystemFonts]);
end;
end;
end;
finally
FreeAndNil(lListPrintableSystemFonts);
end;
end;
end;
-----------------
This works in 99% of all cases, but sometimes for some reason it fails.
Any ideas, suggestions, comments are welcome.
Best regards,
Mark
This discussion has been closed.
Comments
This is not a known issue. The fact that it is happening with RB and
Gnostice leads me to believe that it is a machine/font specific problem.
Do you know if this is occurring only when lFontListToEmbedd.Count > 0?
If possible, please send me a copy of one of the PDF files that displays
the error so I can look at the source for clues as to what is happening.
Send the PDF to support@digital-metaphors.com.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com