Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install fonts on an Azure App Service?

We are using MigraDoc/PDFsharp GDI+ which depends on having fonts installed to the system in order to render. We have tried embedding the fonts but the GDI+ version of MigraDoc does not seem to support this.

When trying to move this component to an Azure App Service, it cannot find the fonts. Is there a way to "install" the fonts locally to the App Service so that they would be visible to GDI?

like image 417
Joey LaMartina Avatar asked Aug 09 '16 18:08

Joey LaMartina


3 Answers

MigraDoc uses PDFsharp to generate PDF files and PDFsharp can use fonts from embedded resources or from files read by the application.

I would use the WPF build of PDFsharp/MigraDoc 1.50 or later and use the IFontResolver interface.

You can use the generic EZFontResolver implementation if that suits your needs:
http://forum.pdfsharp.net/viewtopic.php?f=8&t=3244

like image 168
I liked the old Stack Overflow Avatar answered Oct 10 '22 12:10

I liked the old Stack Overflow


A little late to this - but better late than never!

I have found out that this is actually quite easy - and we all know how!

Add a web.config to the WWWROOT of the app service add the following

You probably don't need to have the < customHeaders > part unless you want CORS

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <directoryBrowse enabled="false" />
        <httpProtocol>
            <customHeaders>
                <add name="Access-Control-Allow-Origin" value="*" />
            </customHeaders>
        </httpProtocol>
        <staticContent>
            <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
            <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
            <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
            <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
        </staticContent>
    </system.webServer>
</configuration>
like image 2
Jerry Weeks Avatar answered Oct 10 '22 12:10

Jerry Weeks


You can use a Windows Container on App Service for installing custom fonts. Here is how:

https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-windows-containers-custom-fonts

For getting started with Windows Containers on App Service:

https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-windows-container

like image 1
Joaquín Vano Avatar answered Oct 10 '22 13:10

Joaquín Vano