Support font.ttf file

Posted by: mayur.purandare on 15 January 2019, 4:25 pm EST

    • Post Options:
    • Link

    Posted 15 January 2019, 4:25 pm EST

    Dear

    I am using this library C1.C1Pdf for generating PDF files.

    I am able to generate PDF file successfully. But I want to apply MS Gothic font on generated pdf file.

    How should I apply MS Gothic font while creating PDF?

  • Posted 16 January 2019, 7:19 pm EST

    Hello,

    You can embed a font in the application and use it for the Font while drawing a string, after you have set the FontType property of C1PdfDocument to Embedded.

    ```

    C1PdfDocument1.FontType = C1.C1Pdf.FontTypeEnum.Embedded

    ’ Add content to the page.

    Dim rect As RectangleF = C1PdfDocument1.PageRectangle

    rect.Inflate(-72, -72)

    Dim pfCol As New System.Drawing.Text.PrivateFontCollection

    pfCol.AddFontFile(“…/…/MS Gothic.ttf”)

    Dim font As Font = New Font(pfCol.Families(0), 12)

    C1PdfDocument1.DrawString(TextBox1.Text, font, Brushes.Black, rect)

    This has been shown in the attached sample. 
    
    Regards,
    Esha[zip filename="prj_PDFDocument_EmbeddedFont.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-8a239378-6247-47f1-a76e-56fa86e2644b.zip[/zip]
  • Posted 1 April 2019, 4:59 pm EST

    Thanks for the reply.

    I got the font from my client. It is a .FON font. It works good on the screen.

    Is there any ways to apply apply .fon font while creating PDF.

  • Posted 2 April 2019, 3:43 pm EST

    Hello,

    .FON files cannot be used while creating PDF , in C1Pdf.

    As per the description in the below mentioned documentation link for FontTypeEnum, ttf files can only be embedded for fonts, in pdf created using C1Pdf:

    https://help.grapecity.com/componentone/NetHelp/c1pdf/webframe.html#C1.C1Pdf.4~C1.C1Pdf.FontTypeEnum.html

    Regards.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels