Reputation: 7301
So I am using a azure website not a web role. Just to be clear.
I am using the DevExpress components to export a report, XRReport
.
I am trying to use a custom font within these reports. Under normal circumstances the XRReport
component would load fonts from the Operating System.
I have tried using PrivateFontCollection
to assign the fonts from the code behind.
private void XtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
PrivateFontCollection fontColl = new PrivateFontCollection();
fontColl.AddFontFile("YourFont.ttf");
XtraReport1 report = (XtraReport1)sender;
foreach (Band b in report.Bands)
{
foreach (XRControl c in b.Controls)
{
c.Font = new Font(fontColl.Families[0], c.Font.Size, c.Font.Style);
}
}
}
However assigning the fonts in this way generates red crosses. See image below.
The solution in my mind is one of two things.
I have seen some scripts to install fonts in web-roles, is there some way to do this in a website?
Is there a different way to assign the fonts in the code behind that works?
Using the code from UsherNet.
DevExpress.XtraPrinting.Export.Pdf.PdfGraphics.EnableAzureCompatibility = true;
The PDF does render now, but they custom font does not appear to have been loaded.
Upvotes: 2
Views: 1353
Reputation: 46
the issue is caused by trust settings on Azure. The quickest solution is to set the property:
DevExpress.XtraPrinting.Export.Pdf.PdfGraphics.EnableAzureCompatibility = true;
More information can be found on the Support Centre web site. http://www.devexpress.com/Support/Center/Question/Details/Q373195
I have published a few report based projects on Azure recently and found the above takes care of the problem described.
Upvotes: 1