PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 5:41 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Embedded Fonts
PostPosted: Thu Feb 11, 2010 1:04 am 
Offline

Joined: Thu Feb 11, 2010 12:57 am
Posts: 3
I am trying to use uninstalled fonts i) from a TTF file and ii) from a resource file
I am using VS2005 (C# Version 2);
I cannot understand what is going on in the sourcecode of PrivateFonts
Can you explain how to do this, with some sample code?
Thanks a lot!
Kevin(aki)


Top
 Profile  
Reply with quote  
 Post subject: Re: Embedded Fonts
PostPosted: Tue Feb 16, 2010 10:32 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Look at the PDFsharp PrivateFonts sample.
http://www.pdfsharp.net/wiki/PrivateFonts-sample.ashx

viewtopic.php?f=2&t=832

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Embedded Fonts
PostPosted: Tue Feb 16, 2010 11:00 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Fonts must be added to XPrivateFontCollection.Global and will be used automatically.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Embedded Fonts
PostPosted: Thu Feb 18, 2010 9:22 pm 
Offline

Joined: Thu Feb 11, 2010 12:57 am
Posts: 3
I tried to use PrivateFonts: I think you have some VS2008 specific code (does not compile in 2005);
I tried substituting 'var' and calling AddFont and it crashed at runtime;
Do you have a sample in VS2005: I am not really sure what is happening in the code;
Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: Embedded Fonts
PostPosted: Mon Feb 22, 2010 9:09 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
The sample uses WPF - and WPF requires AFAIK VS 2008.

For a GDI+ sample, please download PDFsharp 1.2 (the sample is not included in the sample solution, but it's in the samples folder).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Embedded Fonts
PostPosted: Fri Feb 26, 2010 11:20 pm 
Offline

Joined: Fri Feb 26, 2010 11:15 pm
Posts: 10
Thomas,

I am trying to add private fonts. sample code

PdfDocument doc = new PdfDocument();
PdfPage page = doc.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XPrivateFontCollection fnt = XPrivateFontCollection.Global;
fnt.Add(new Uri("C:\\Windows\\Fonts\\CCHSYM2.TTF"), "#CCHSymbolTwo");
XFontStyle styleToUse = XFontStyle.Regular;
XColor glyphColor = XColor.FromArgb(000);
XBrush glyphBrush = new XSolidBrush(glyphColor);
XStringFormat textFormat = XStringFormats.Default;
XPdfFontOptions fontOptions = new XPdfFontOptions(PdfFontEncoding.WinAnsi, PdfFontEmbedding.Default);
XFont fontToUse = new XFont("CCHSymbolTwo", 1, styleToUse, fontOptions);
gfx.DrawString("d", fontToUse,
glyphBrush, 140, 140,
XStringFormats.Default);
doc.Save("c:\\xaml\\sharp.pdf");


I am getting Assertion from the file opentypedescriptor.cs (193)

Err: Pdf Sharp internal: Ascender should be less than 0


Top
 Profile  
Reply with quote  
 Post subject: Re: Embedded Fonts
PostPosted: Mon Mar 01, 2010 9:13 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
ganpp wrote:
I am getting Assertion from the file opentypedescriptor.cs (193)

If it works, ignore (or comment) the assertion.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Embedded Fonts
PostPosted: Mon Mar 01, 2010 11:20 pm 
Offline

Joined: Fri Feb 26, 2010 11:15 pm
Posts: 10
Thomas,

These are special fonts like checkbox. Yes, I ignored the assertion and it works. I add it XForm and add it to a page.


Thx,
Ganesh


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 379 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