I've tried my snippet of code below and it doesn't appear to embed any font i use into the pdf. The font's used in this example are from google fonts and then one custom one.
How can i get these fonts to embed into the PDF since the user open the pdf most likely doesn't have these fonts? I've looked around online for a long time an no one appears to have a working solution that i've come across. This is using pdfsharp 1.32.2608.0
Code:
public static void DefaultPDF()
{
// Template Brushes
XBrush orangeBrush = new XSolidBrush(XColor.FromArgb(241, 95, 59));
XBrush blackBrush = new XSolidBrush(XColor.FromArgb(0,0,0));
// Template Fonts
XFont fontHeader = new XFont("Republic Heavy", 85, XFontStyle.Bold);
XFont fontSub = new XFont("Republic Heavy", 55, XFontStyle.Bold);
XFont fontPar = new XFont("Source Sans Pro Light", 55, XFontStyle.Regular);
// Create a new PDF document
PdfDocument document = new PdfDocument();
// Create first page (8.5 x 11)
PdfPage page = new PdfPage();
page.Width = 2550;
page.Height = 3300;
page.Orientation = PageOrientation.Portrait;
// add page to document
document.Pages.Add(page);
// drawing graphics
XGraphics gfx = XGraphics.FromPdfPage(page);
// embed fonts into PDF
gfx.MFEH = PdfFontEmbedding.Always;
// add Text
gfx.DrawString("Company Name Project Proposal", fontHeader, XBrushes.Black, new XRect(285, 680, page.Width, page.Height), XStringFormats.TopLeft);
gfx.DrawString("Schedule A", fontSub, XBrushes.Black, new XRect(285, 780, page.Width, page.Height), XStringFormats.TopLeft);
gfx.DrawString("testing the paragraph font", fontPar, XBrushes.Black, new XRect(285, 880, page.Width, page.Height), XStringFormats.TopLeft);
// Save the document...
const string filename = "PageSizes_tempfile1.pdf";
document.Save(filename);
Process.Start(filename);
}