Pdfsharp - insert a font?

I am given a file with a different language font. They cannot download the font, so they want me to embed it in pdf.

Now I only have a PDF reader, so I can not edit or create a PDF file. so I decided to quickly do it in C # .NET using the PDFSharp library, but I just can't figure out how to embed fonts using pdfSharp ?!

Also, this is only 1 file that I have to process, so if you know a way to do it manually, that would be great too.

+6
pdfsharp
source share
1 answer

There are two ways to do this. For each font that you want to insert as follows:

var options = new XPdfFontOptions(PdfFontEmbedding.Always); var font = new XFont("Times New Roman", 12, XFontStyle.Regular, options); 

Then, if you use a font, it will be embedded.

If you want all fonts to be used on the embedded page, you can do this as follows:

 var page = new PdfPage(); var gfx = XGraphics.FromPdfPage(page); gfx.MFEH = PdfFontEmbedding.Automatic; 

The second approach will work for any fonts used in the MigraDoc code.

+14
source share

All Articles