Can I embed ttf in pdf?

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  Can I embed ttf in pdf?

DynamicPDF CoreSuite for .NET (v10) Forum

 Mar 05 2020 11:54 PM
I created two pdf documents that one used otf (courier) and one used ttf (courier).
Each document looks different.
Text of documents that use otf appear higher than text of documents that use ttf.
Is there a way to display the same no matter what font is used?
If it is not possible, can I embed ttf in pdf document?
 Mar 06 2020 9:26 AM
Posted by a ceTe Software moderator
Hello,

The OTF and TTF are different font types and the characteristics may be different. There could be a difference in the way they display the text even though the name of the font is same. 

If you would like to embed an OTF or TTF font in the PDF then you will need to load a TTF or OTF font into an OpenTypeFont object. Set the Embed property to true and Subset to false then use it in your page elements. Here is some sample code:

            Document document1 = new Document();
            Page page1 = new Page();
            document1.Pages.Add(page1);
            OpenTypeFont font1 = new OpenTypeFont(@"TTF or OTF font file path");
            font1.Embed = true;
            font1.Subset = false;
            //TextArea with fully embeddd Font.
            TextArea txt1 = new TextArea("Embedd: ", 20, 40, 200, 100);
            txt1.Font = font1;
            txt1.FontSize = 8.0f;
            page1.Elements.Add(txt1);
            string output1 = @"File path to save the PDF ";
            document1.Draw(output1);

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 8:57 PM.