In this tutorial we will be deploying the JSViewer_MVC_Core sample on Azure using a Linux environment.
CustomFontResolver.cs |
Copy Code
|
---|---|
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; } } |
Startup.cs |
Copy Code
|
---|---|
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.