I am trying to generate a PDF with a font embedded but it does not seem to embed the font. It is a truetype font and is installed in Windows - the PDf displays the font correctly on this computer. If I open the PDF on a different computer without the font installed, the PDF displays with the incorrect font so I assume it is not embedded. Any idea what I am doing wrong (sample program below)?
If it is possible to get the font embedded then it is likely we would move to a full licence of the product.
We are using FreeSpire.PDF version 3.2
(packages\FreeSpire.PDF.3.2\lib\net40-client\Spire.Pdf.dll)
Many thanks,
Nathan
- Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Graphics;
namespace Font
{
class Program
{
static void Main(string[] args)
{
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
PdfBrush brush = new PdfSolidBrush(Color.Red);
System.Drawing.Font font = new System.Drawing.Font("Rats-Irreverence", 14f, FontStyle.Bold);
PdfTrueTypeFont trueTypeFont = new PdfTrueTypeFont(font);
page.Canvas.DrawString("Font Family: Rats-Irreverenc - Embedded", trueTypeFont, brush, 16f, 16f);
doc.SaveToFile("Font.pdf");
doc.Close();
System.Diagnostics.Process.Start("Font.pdf");
}
}
}