Hi, I have this section in my web.config file:
<Telerik.Reporting>
<privateFonts>
<add fontFamily="Arial Narrow" path="~\Fonts\ARIALN.TTF" />
</privateFonts>
</Telerik.Reporting>
..and when I start the web application from VS2015 in debug mode, when the first report rendering starts, it throws and exception, and from it's description I can see that the report processing engine looks for fonts in:
C:\\Program Files (x86)\\IIS Express\\~\\Fonts\\ARIALN.TTF
I have also tried "path=Fonts\ARIALN.TTF" and it looks in C:\\Program Files (x86)\\IIS Express\\Fonts\\ARIALN.TTF
Please tell me how to setup my web.config file in order for fonts to be located in the "Fonts" sundirectory of my application?
12 Answers, 1 is accepted
Below is a quote from my response in your support ticket on the same question.
Please modify the project in the attachment to reproduce the problem. The project uses Telerik Reporting R2 2017 v11.1.17.503 and the following configuration:
<
configuration
>
<
configSections
>
<
section
name
=
"Telerik.Reporting"
type
=
"Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting, Version=11.1.17.503, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
allowLocation
=
"true"
allowDefinition
=
"Everywhere"
/>
</
configSections
>
<
Telerik.Reporting
>
<
privateFonts
>
<
add
fontFamily
=
"One Way"
path
=
"~\Fonts\oneway.TTF"
/>
</
privateFonts
>
</
Telerik.Reporting
>
The mentioned project is available as an attachment in your support ticket.
Please let us continue the discussion in one of both threads in order to keep a better track on the exchanged information.
Thank you for your understanding.
Regards,
Stef
Progress Telerik
Hello Stef,
I have exactly the same problem in my web application.
When I specify path="~\Fonts\ocrb10.ttf", Telerik Reporting looks for the font at C:\Windows\System32\InetSrv\~\Fonts\ocrb10.ttf.
When I specify path="Fonts\ocrb10.ttf", Telerik Reporting looks for the font at C:\Windows\System32\InetSrv\Fonts\ocrb10.ttf.
When I specify path="\Fonts\ocrb10.ttf", Telerik Reporting looks for the font at C:\Fonts\ocrb10.ttf.
What can I do to have the looked at the Fonts subfolder of the application?
The configuration file contains the following:
<
Telerik.Reporting
>
<
privateFonts
>
<
add
fontFamily
=
"OCRB10"
path
=
"~\Fonts\ocrb10.ttf"
/>
</
privateFonts
>
</
Telerik.Reporting
>
Hello,
I have tried to change the current directory with
Directory.SetCurrentDirectory(HttpRuntime.AppDomainAppPath);
at the application startup.
This works on my development machine, but not on the production machine. When I try to generate a report, I now have the following error message.
Error: System.TypeInitializationException: The type initializer for 'Telerik.Reporting.Processing.Common.FontContainer' threw an exception. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Windows\SysWOW64\inetsrv\Fonts\ocrb10.ttf'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Telerik.Reporting.Processing.Common.FontContainer.AddFontCore(String filePath, String absolutePath, String fontFamily, String fontStyle)
at Telerik.Reporting.Processing.Common.FontContainer.AddFont(String filePath, String fontFamily, String fontStyle)
at Telerik.Reporting.Processing.Common.FontContainer.InitializePrivateFontCollection()
at Telerik.Reporting.Processing.Common.FontContainer..ctor()
at Telerik.Reporting.Processing.Common.FontContainer..cctor()
--- End of inner exception stack trace ---
at Telerik.Reporting.Drawing.FontExtensions.GetStyle(IFont font)
at Telerik.Reporting.Drawing.FontExtensions.ToGdiFont(IFont font)
at Telerik.Reporting.Processing.GdiFontInfoCache.CreateValue(IFont font)
at Telerik.Reporting.Processing.GdiFontCache`1.GetValue(IFont font)
at Telerik.Reporting.Processing.MeasureContext.CalculateLineHeight(IFont font)
at Telerik.Reporting.Processing.TextRenderer.MeasureText(IMeasureContext context, String text, IFont font, RectangleF layoutRectangle, TextFormat textFormat, Boolean multiline, Int32& charactersFitted)
at Telerik.Reporting.Processing.TextBoxUtil.MeasureTextContainer(ITextContainer textContainer, RectangleF layoutBounds, IMeasureContext context)
at Telerik.Reporting.Processing.TextBox.MeasureItem(IMeasureContext context, SizeLU availableClientSize, Boolean canGrow)
at Telerik.Reporting.Processing.TextBox.MeasureItem(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.TextBox.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.AbsolutePositionLayout.MeasureChildItems(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.AbsolutePositionLayout.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.ReportSectionBase.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.StackLayout.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.Group.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.StackLayout.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.Report.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.SubReport.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.AbsolutePositionLayout.MeasureChildItems(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.AbsolutePositionLayout.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.ReportSectionBase.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.StackLayout.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.Group.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.StackLayout.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.Report.MeasureContent(IMeasureContext context, SizeLU availableClientSize)
at Telerik.Reporting.Processing.LayoutElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.VisualElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Processing.ProcessingElement.MeasureCore(IMeasureContext context, SizeLU availableSize)
at Telerik.Reporting.Paging.PhysicalPageLayout.PhysicalPageMeasurement.MeasureRoot(LayoutElement root, IMeasureContext measureContext, PageSettings pageSettings)
at Telerik.Reporting.BaseRendering.RenderingExtensionBase.MeasureRootCore(LayoutElement root, IMeasureContext measureContext, PageSettings pageSettings)
at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(LayoutElement root, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback, PageSettings pageSettings)
at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback)
at Telerik.Reporting.Processing.ReportProcessor.RenderCore(ExtensionInfo extensionInfo, IList`1 processingReports, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRender(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRenderStateless(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo)
at Asloca.Reports.PdfReportInfo.GeneratePdf(IReportDocument Report, String DocTitle)
at Asloca.Reports.BvrReportInfo.Generate()
at Asloca.Member.PrintBvrService.ProcessRequest(HttpContext Context, XElement Request, LoggedOnUser User)
at Asloca.Net.XmlRequestHttpHandler.ProcessRequest(HttpContext Context, XElement Request, LoggedOnUser User, Int32 No)
The PrivateFonts font container depends on the HttpContext.Current.Server.MapPath(filePath) to resolve the font filepath. Do you invoke the ReportProcessor.RenderReport from a custom Thread/Task? If this is the case make sure the HttpContext.Current is passed to the thread. How to do this is explained in this stackoverflow article.
Regards,
Peter
Progress Telerik
Hi Peter,
Thank you for your answer.
Unfortunately, the link to the stackoverflow article is not correct: it links to a screenshot.
Regards
I have fixed the link. I hope it helps.
Regards,
Peter
Progress Telerik
Hello Peter,
I no more have the error message saying that the font is not found, but the report is not correct.
For example, where the OCR-B content should be 042>892848142971320180001305052+ 010080961
It is displayed as 153􀀡9􀀜3959253􀀜82431291112416163􀀎 121191􀀜72􀀡
It seems that the Unicode value of each char is incremented by 1!
Do you have an explanation?
Regards
Pater, an additional note:
The problem is only on the production system, on my development PC the result is correct, with the same font! But the font was installed on my PC and not on the production system.
Do I need to add other font files (.afm, .pfb, .pfm)?
Regards
TTF is supported font type. Considering that it is embedded correctly by the application, the produced result should be the same in both environments.
We would need to check the settings of the report where the font is used, the application configuration file where the font is embedded and the font itself in order to provide you further suggestions. You can send this information in a new support ticket.
Regards,
Katia
Progress Telerik
Hi Katia,
Support ticket created.
Regards
Hi,
Does the private fonts support otf type?
Hello Naureen,
Officially we support only TTF fonts.
You may test with OTF as GDI+ we use internally supports OTF - check the table at the bottom of Creating a Private Font Collection Microsoft article. We cannot guarantee that reports will be rendered correctly with fonts other than TTF though.
Regards,
Todor
Progress Telerik