PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help Embed ttf Font from a file

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
pman



Joined: 14 Feb 2008
Posts: 2

PostPosted: Thu Feb 14, 2008 7:30 pm    Post subject: help Embed ttf Font from a file Reply with quote

Dim fn As System.Drawing.Font
fn = New Font(ffUtopia, 14, GraphicsUnit.World)

gfx.DrawString(stmp, XPdfFont, XBrushes.Black, xStart, yStart)


i get a "Object Reference not set to an instance of an object" error
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Mon Feb 18, 2008 8:01 am    Post subject: Reply with quote

PDFsharp 1.0 requires some changes to fully support private font collections.
Changes will be published with PDFsharp 1.1.

Recommended workaround: install the TTF file.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
pman



Joined: 14 Feb 2008
Posts: 2

PostPosted: Tue Feb 19, 2008 3:37 pm    Post subject: thanks Reply with quote

Hey Thanks Thomas

a quick question... will it only work with TTF fonts?

thanks
do you have a sample on how to reference it ...thanks
Back to top
View user's profile Send private message
jmiko



Joined: 09 Feb 2009
Posts: 3

PostPosted: Mon Feb 09, 2009 2:18 am    Post subject: Reply with quote

I cannot embed private fonts. I have version 1.2. Has this been added?
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Mon Feb 09, 2009 11:23 am    Post subject: Reply with quote

Look for XPrivateFontCollection.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
jmiko



Joined: 09 Feb 2009
Posts: 3

PostPosted: Mon Feb 09, 2009 11:07 pm    Post subject: Reply with quote

I am using the XPrivateFontCollection but it will not embed the fonts. I will try to post the code I'm using later.

Are there any samples?
Back to top
View user's profile Send private message
jmiko



Joined: 09 Feb 2009
Posts: 3

PostPosted: Mon Feb 09, 2009 11:21 pm    Post subject: Reply with quote

Ok I feel stupid now. I got it working

Code:
string pdfFileName = @"c:\test.pdf";
string fontFileName = @"c:\daniel.ttf";

XPrivateFontCollection privateFonts = new XPrivateFontCollection();
byte[] fontData = File.ReadAllBytes(fontFileName);
privateFonts.AddMemoryFont(fontData, fontData.Length, "Daniel", false, false);

using (PdfDocument doc = new PdfDocument())
{
  PdfPage page = doc.AddPage();
  using (XGraphics gfx = XGraphics.FromPdfPage(page))
  {
    XPrivateFont pfont = privateFonts.FindFont("Daniel", false, false);
    XPdfFontOptions fontOptions = new XPdfFontOptions(PdfFontEncoding.WinAnsi, PdfFontEmbedding.Always);
    FontFamily family = new FontFamily("Daniel", privateFonts.PrivateFontCollection);
    XFont xfont = new XFont(family, 18, XFontStyle.Regular, fontOptions, privateFonts);
    gfx.DrawString("Hello World", xfont, Brushes.Black, 50, 50);
  }

  doc.Save(pdfFileName);
}

System.Diagnostics.Process.Start(pdfFileName);
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Tue Feb 10, 2009 9:19 am    Post subject: Reply with quote

Thank you for the sample code.

XPrivateFontCollection is not yet covered by our samples.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com