[]
In this tutorial we will be deploying the JSViewer_MVC_Core sample on Azure using a Linux environment.
Add a new folder Fonts in the project where we will the required fonts.
Add a new .cs file 'CustomFontResolver.cs' and make sure to set the Build Action to 'Embedded Resource'.
Add the following code in the .cs file to the add the script.
using GrapeCity.Documents.Text.Windows;
public sealed class CustomFontResolver : GrapeCity.ActiveReports.IFontResolver
{
static readonly GrapeCity.Documents.Text.FontCollection _fonts = new GrapeCity.Documents.Text.FontCollection();
static CustomFontResolver()
{
_fonts.Clear();
var assembly = Assembly.GetExecutingAssembly();
var fontnames = assembly.GetManifestResourceNames().Where(str => str.EndsWith(".ttf"));
foreach (var fontname in fontnames)
{
Stream stream = assembly.GetManifestResourceStream(fontname);
_fonts.Add(GrapeCity.Documents.Text.Font.FromStream(stream));
}
_fonts.DefaultFont = _fonts.FindFamilyName("Arial");
}
public static GrapeCity.ActiveReports.IFontResolver Instance = new CustomFontResolver();
private CustomFontResolver() { }
GrapeCity.Documents.Text.FontCollection GrapeCity.ActiveReports.IFontResolver.GetFonts(string familyName, bool isBold, bool isItalic)
{
var fonts = new GrapeCity.Documents.Text.FontCollection();
var font = _fonts.FindFamilyName(familyName, isBold, isItalic);
if (font != null) fonts.Add(font);
fonts.Add(_fonts.DefaultFont);
return fonts;
}
}
In Startup.cs, specify the UseFontResolver property in the JavaScript Viewers as in the following code example.
app.UseReportViewer(settings =>
{
settings.UseFontResolver = CustomFontResolver.Instance;
settings.UseEmbeddedTemplates(EmbeddedReportsPrefix, Assembly.GetAssembly(app.GetType()));
settings.UseCompression = true;
});
Follow these steps to create your App Service resources and publish your project. Let us use JSViewer_MVC_Core sample project for demonstration purpose.