PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jun 17, 2024 1:55 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Jul 13, 2010 2:40 pm 
Offline

Joined: Tue Jul 13, 2010 2:32 pm
Posts: 3
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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 14, 2010 1:50 pm 
Offline

Joined: Tue Jul 13, 2010 2:32 pm
Posts: 3
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu Dec 30, 2010 10:27 am 
Offline

Joined: Thu Dec 30, 2010 10:07 am
Posts: 2
For me it shows: System.UriFormatException: Invalid URI: Invalid port specified.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 07, 2012 4:31 pm 
Offline

Joined: Thu Jan 05, 2012 3:14 am
Posts: 8
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 166 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group