PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Private fonts okay in WPF demo, need help using it in webapp
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1255
Page 1 of 1

Author:  alain.bourdiaudhy [ Tue Jul 13, 2010 2:40 pm ]
Post subject:  Private fonts okay in WPF demo, need help using it in webapp

Hi, after reading the topics about using private fonts, i decided to switch from GDI+ to WPF version of PDFSharp.
I'm trying to use a specific font in our pdf document.
I adapted the demo app and it shows the font just fine.

My problem is that i need to use it in a web application.
There i allways get the exception "Font with the specified family name does not exist." (XPrivateFontCollection.cs line 248)

Is there a special need that i'm not aware of to get my font picked up ?

This is the code i'm using:
Code:
            XPrivateFontCollection globalFontCollection = XPrivateFontCollection.Global;
            // Without the following line of code the Uri constructor (see below) fails...
            new System.Windows.Application();
            Uri uri = new Uri("pack://application:,,,/");
            const string name = "./fonts/#Echelon";
            globalFontCollection.Add(uri, name);


Any help would be greatly appreciated !
Thanks, Alain.

Author:  alain.bourdiaudhy [ Wed Jul 14, 2010 1:50 pm ]
Post subject:  Re: Private fonts okay in WPF demo, need help using it in webapp

Quickly answering my own question. Maybe it will help someone else.

The problem was that my webapp was creating the pdf in a separate assembly. It was also that assembly that contained the font i was using in it's resources.

So the Uri definition had to become
Code:
Uri uri = new Uri("pack://application:,,,/AssemblyName;component/");

where AssemblyName had to be the actual name of the assembly that contained the font resource.

Hope this helps someone.

Author:  ilya.bolkhovsky [ Thu Dec 30, 2010 10:27 am ]
Post subject:  Re: Private fonts okay in WPF demo, need help using it in webapp

For me it shows: System.UriFormatException: Invalid URI: Invalid port specified.

Author:  TraderGordo [ Sat Jan 07, 2012 4:31 pm ]
Post subject:  Re: Private fonts okay in WPF demo, need help using it in webapp

ilya.bolkhovsky wrote:
For me it shows: System.UriFormatException: Invalid URI: Invalid port specified.

I know this post is old, but for people searching for this in the future, your answer can be found here:
viewtopic.php?f=2&t=1880

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/