PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
emebdded font in MigraDoc table? https://forum.pdfsharp.net/viewtopic.php?f=2&t=732 |
Page 1 of 1 |
Author: | mikesowerbutts [ Fri May 15, 2009 3:36 pm ] |
Post subject: | emebdded font in MigraDoc table? |
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 |
Author: | Thomas Hoevel [ Mon May 18, 2009 8:19 am ] |
Post subject: | |
Hi! MigraDoc uses PDFsharp. Font embedding works with MigraDoc, too. No workaround needed. |
Author: | mikesowerbutts [ Mon May 18, 2009 8:23 am ] |
Post subject: | |
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";
|
Author: | Thomas Hoevel [ Mon May 18, 2009 8:35 am ] |
Post subject: | |
Yes, but don't forget to pass the private font collection to the Renderer: Code: DocumentRenderer renderer = new DocumentRenderer(document);
renderer.PrivateFonts = this.PrivateFontCollection; |
Author: | mikesowerbutts [ Mon May 18, 2009 9:03 am ] |
Post subject: | |
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? |
Author: | Thomas Hoevel [ Mon May 18, 2009 9:21 am ] |
Post subject: | |
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; |
Author: | mikesowerbutts [ Mon May 18, 2009 9:45 am ] |
Post subject: | |
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(); |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |