[]
This page demonstrates how you can deploy your ActiveReports application on AWS using a Linux Environment.
Add a new folder Fonts in the project where we will add the required fonts.
Add all the required fonts in the Fonts folder and then
make sure to set the Build Action of the font files to ‘Embedded Resource'.
OR
add the following lines of code to the JSViewer_MVC_Core.csproj file to copy all the fonts to the build folder:
<ItemGroup>
<Content Include="Fonts**\*.ttf**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
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;
});
Once you have set up everything the next step is to create a user in your AWS Account. You can also visit AWS Docs for more information.
Open the Sign In Page.
type=note
Note: If you are new to AWS then Sign Up to AWS and add MFA Authentication by logging in as a Root User first.
Select IAM user and enter your credentials.
Now from the AWS Management Console under All Services, select IAM. This will open the IAM Dashboard.
Select Users under the Access Management group
Click Add users on the top right of your screen. This will open the Add user page.
Set the User name. Here, for documentation purposes, we are adding 'AR_Deployment_Agent' as the username.
Select the Access key-Programmatic access that gives this user programmatic access. Then click Next: Permissions.
Now we will add a user to a group. Select an existing group or create a new group:
a. Click on Create a Group option.
b. Enter the Group Name. Here we are using 'AR_Deployment_Agents' as the group name.
c. In the policies option, check AdministratorAccess-AWSElasticBeanstalk and IAMFullAccess.
d. Click Create group.
Click Next: Tags. Here you can add the tags that can be used in your application for now we are going to skip this.
Click Next: Review. Here, you can review the user properties and then select Create user.
Now copy the Access key ID and Secret access key and save it.
Note you can also download the CSV from this page.
Now that we have set up everything on the AWS account, let us set up our application with AWS and deploy it on the cloud.
Open the JSViewer_MVC_Core sample in Visual Studio.
From View, go to AWS Explorer.
In the AWS Explorer window, click the “+” icon to create a new profile.
Enter a Profile Name (AR_Cloud_Deploy), the saved Access Key ID, and the Secret Access Key.
Note that you can also import the CSV if you chose to download it while creating the user account.
To publish your application for AWS Elastic Beanstalk, follow these steps.
To avoid any incurring charges if you are done working with Elastic Beanstalk for now, you can terminate your .NET environment. To terminate your Elastic Beanstalk environment: