PDF Mosaic: How to load OpenType font using PDF Mosaic .NET Library


Home       Features       Download       Tutorial       Version History       License       Source Code

 

The example demonstares how to write text using OpenType Font with help of PDF Mosaic .NET Library.

How to write text using OpenType Font with help of PDF Mosaic .NET Library
 

C# :

using PDFMosaic;
using System.Drawing;
 
namespace OpenTypeFont
{
  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();
 
      PDFFont fontFromFile = PDFFont.FromFile("c:\\fummel.otf", 12);
      canvas.DrawString("opentype Font from file.", fontFromFile, brush, 10, 120);
 
      document.Save("OpenTypeFont.pdf", true);
    }
  }
}

 

Visial Basic.NET :

Imports PDFMosaic
Imports System.Drawing
 
Module OpenTypeFont
  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()
 
    Dim fontFromFile = PDFFont.FromFile("c:\\fummel.otf", 12)
    canvas.DrawString("Font from file.", fontFromFile, brush, 10, 120)
 
    document.Save("OpenTypeFont.pdf", True)
  End Sub
End Module

 


Home       Features       Download       Tutorial       Version History       License       Source Code