I have a Crystal report, which is currently used with Delphi 7 applications which serves years now without any issue. After processing application exports report as a PDF.
Recently, I made another application using .Net 3.5 (Can't go beyond that since we use some old custom controls). When I use the same report (to export as PDF) using that application I get some additional charactors on "Static Labels".
Example :
Static Text on report -> Klant nummer What we get on PDF -> Klanti nummer (There is an additional "i")
For all text lables report has used "Calibri" Font. Later I noticed when I change the font type to "Arial" it works fine.
But I cannot do that since this is an official invoice need to be in same format(font) from all the applications.
Why it gives correct output from Delphi and not in .Net?
We can change the font of the report programmatically in the following way, it also solves the issue.
private void updateReport(ReportDocument doc)
{
Font ft;
foreach (Section sec in doc.ReportDefinition.Sections)
{
foreach (ReportObject obj in sec.ReportObjects)
{
if (obj.Kind == ReportObjectKind.FieldHeadingObject)
{
FieldHeadingObject fobj = (FieldHeadingObject)obj;
ft = new Font("Arial", fobj.Font.Size, fobj.Font.Style, fobj.Font.Unit,
fobj.Font.GdiCharSet, fobj.Font.GdiVerticalFont);
fobj.ApplyFont(ft);
}
else if (obj.Kind == ReportObjectKind.FieldObject)
{
FieldObject fobj = (FieldObject)obj;
ft = new Font("Arial", fobj.Font.Size, fobj.Font.Style, fobj.Font.Unit,
fobj.Font.GdiCharSet, fobj.Font.GdiVerticalFont);
fobj.ApplyFont(ft);
}
else if (obj.Kind == ReportObjectKind.TextObject)
{
TextObject fobj = (TextObject)obj;
ft = new Font("Arial", fobj.Font.Size, fobj.Font.Style, fobj.Font.Unit,
fobj.Font.GdiCharSet, fobj.Font.GdiVerticalFont);
fobj.ApplyFont(ft);
}
}
}
}