PDF Mosaic: How to load font from filename (TTF) to use in PDF document generated by .NET library PDF Mosaic


Home       Features       Download       Tutorial       Version History       License       PDF Mosaic Blog       Source Code

 

This sample shows how to add and use text font from file.

This sample shows how to add and use text font from file in PDF Mosaic library
 

C# :

/*
Description:
This sample shows how to use fonts in PDFMosaic library.
 
*/
using PDFMosaic;
using System.Drawing;
 
namespace FontFromFile
{
  class Fonts
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
      PDFCanvas canvas = document.Pages[0].Canvas;
 
      PDFBrush brush = new PDFSolidBrush();
 
      // load font from filename
      PDFFont fontFromFile = PDFFont.FromFile("..\\..\\arial.ttf", 12);
      canvas.DrawString("Font from file.", fontFromFile, brush, 10, 120);
 
      document.Save("FontFromFile.pdf", true);
    }
  }
}

 

Visial Basic.NET :

'Description
'This sample shows how to use fonts in PDFMosaic library.
'
 
Imports PDFMosaic
Imports System.Drawing
 
Module FontFromFile
  Sub Main()    
    Dim document As New PDFDocument()
    document.Pages.Add(New PDFPage(PDFPaperFormat.A4))
    Dim canvas = document.Pages(0).Canvas
 
    Dim brush As New PDFSolidBrush()
 
    ' load font from filemane
    Dim fontFromFile = PDFFont.FromFile("..\\..\\arial.ttf", 12)
    canvas.DrawString("Font from file.", fontFromFile, brush, 10, 120)
 
    document.Save("FontFromFile.pdf", True)
  End Sub
End Module

 


Home       Features       Download       Tutorial       Version History       License       PDF Mosaic Blog       Source Code