Hi everyone.
First off I'd like to say that I know there are exaples and samples available but I've tried them and even though the compiled samples from the source-forge download work I can't get the same results in my own app.
I am using PdfSharp and MigraDoc 1.31. At first I used the GDI+ versions but I switched to the WPF version.
Some background on my app. My app is a website (.Net MVC 2). I wish to serve dynamically created pdf documents (invoices) to users as part of the functionality. The code that generates the pdf documents is a C# class library which references the PdfSharp and MigraDoc dll's.
So far I've been able to successfull create the documents complete with headers and footers and page count indicators using MigraDoc 1.31. I use MigraDoc to generate the documents and then render it to pdf.
The next step is to use a specific font for some of the text. As far as I can tell I can do this by embedding the font. This is where I strike out though.
My app is not wpf. It's MVC.
I have copied the code from the Private Fonts sample:
Code:
// Without the following line of code the Uri constructor (see below) fails...
new System.Windows.Application();
// Add the 3 type faces of 'FrutigerLight' from the resources
Uri uri = new Uri("pack://application:,,,/");
//const string name = "./FrutigerFonts/#FrutigerLight";
//const string name = "./Fonts/#Early Tickertape";
const string name = "./#Early Tickertape";
globalFontCollection.Add(uri, name);
// Add 2 type faces of 'Frutiger' from the resources
//globalFontCollection.Add(uri, "./FrutigerFonts/#Frutiger");
//globalFontCollection.Add(uri, "./Fonts/#Oblivious font");
globalFontCollection.Add(uri, "./#Oblivious font");
Running the sample works fine, but in my app an exception s thrown stating Invalid URI: A port was expected because of there is a colon (':') present but the port could not be parsed.
My code looks like this:
Code:
private void EmbedFont()
{
Uri uri = new Uri("pack://application:,,,/");
XPrivateFontCollection globalFontCollection = XPrivateFontCollection.Global;
globalFontCollection.Add(uri, "./#Avenir LT Std 65 Medium");
}
I've been trying to figure this out for a solid day now and all I've got so far is tired and frustrated. Please help!