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 

emebdded font in MigraDoc table?

 
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
mikesowerbutts



Joined: 15 May 2009
Posts: 4

PostPosted: Fri May 15, 2009 3:36 pm    Post subject: emebdded font in MigraDoc table? Reply with quote

Hi,

I am creating a table and adding a paragraph object to each cell, then adding text to the paragraph objects, but I noticed that there is a property:
Code:
paragraph.Format.Font.Name = "Arial Unicode MS";

I can embed any ttf font in PDFSharp as i have already experimented with this as the project i am working on will require unicode language support. I have it working for PDFSharp, but i cant seem to find out how to do it for tables in MigraDoc?

If there is no way of embedding ttf fonts for use in MigraDoc objects, is there a workaround to create the table in MigraDoc, then add the text with PDFSharp BUT keep the word wrapping functionality of the MigraDoc paragraph object?

Thanks!

Mike
Back to top
View user's profile Send private message
Thomas Hoevel



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

PostPosted: Mon May 18, 2009 8:19 am    Post subject: Reply with quote

Hi!

MigraDoc uses PDFsharp.

Font embedding works with MigraDoc, too.
No workaround needed.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
mikesowerbutts



Joined: 15 May 2009
Posts: 4

PostPosted: Mon May 18, 2009 8:23 am    Post subject: Reply with quote

so can i just create the embedded fotn object in PDFSHarp like this:
Code:

// Load in font
string fontFileName = @"C:\Users\sowemi\Desktop\ARIALUNI.TTF";
XPrivateFontCollection privateFonts = new XPrivateFontCollection();
byte[] fontData = File.ReadAllBytes(fontFileName);
privateFonts.AddMemoryFont(fontData, fontData.Length, "Arial Unicode MS", false, false);
XPrivateFont pfont = privateFonts.FindFont("Arial Unicode MS", false, false);
 XPdfFontOptions fontOptions = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
XFont xFont = new XFont(family, 18, XFontStyle.Regular, fontOptions, privateFonts);

And then use it in a MigraDoc table's cell like this:
Code:

paragraph.Format.Font.Name = "Arial Unicode MS";
Back to top
View user's profile Send private message
Thomas Hoevel



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

PostPosted: Mon May 18, 2009 8:35 am    Post subject: Reply with quote

Yes, but don't forget to pass the private font collection to the Renderer:
Code:
DocumentRenderer renderer = new DocumentRenderer(document);
renderer.PrivateFonts = this.PrivateFontCollection;

_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
mikesowerbutts



Joined: 15 May 2009
Posts: 4

PostPosted: Mon May 18, 2009 9:03 am    Post subject: Reply with quote

I am now passing my privateFonts variable to renderer.PrivateFonts like this:
Code:

DocumentRenderer renderer = new DocumentRenderer(document);
renderer.PrivateFonts = privateFonts;
renderer.PrepareDocument();
renderer.RenderPage(gfx,1);


and I am creating the privateFonts object further up in my code like this:
Code:

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


But when i put a unicode character into my table, it wont embed!

I looked at the fonts tab in the pdf's properties and its saying im using Arial Unicode MS, but its not embedded and its using Ansi encoding. Dont I have to create a MigraDoc.DocumentObjectModel.Font object and tell it to "always embed fonts" and "use unicode encoding" like I do with the PDFSharp XFont object?
Back to top
View user's profile Send private message
Thomas Hoevel



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

PostPosted: Mon May 18, 2009 9:21 am    Post subject: Reply with quote

You specify this when creating the PdfDocumentRenderer.

Rendering to PDF goes like this:
Code:
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfSharp.Pdf.PdfFontEmbedding.Always);
renderer.Document = document;

_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
mikesowerbutts



Joined: 15 May 2009
Posts: 4

PostPosted: Mon May 18, 2009 9:45 am    Post subject: Reply with quote

OK I am now using PdfDocumentRenderer rather than DocumentRender as before, but it just isnt creating my table in the PDF now?

i am using this:
Code:

PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
renderer.Document = document;
renderer.RenderDocument();
Back to top
View user's profile Send private message
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