PDF Mosaic: How to use fonts


Home       Features       Download       License       Tutorial       Version History       Source Code

 

This sample shows how to use fonts in PDF Mosaic library.


 

C# :

using PDFMosaic;
using System.Drawing;
 
namespace Fonts
{
  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 systemFont = new PDFFont("Arial", 12);
      canvas.DrawString("The system font.", systemFont, brush, 10, 60);
 
      PDFFont standardFont = new PDFFont(PDFStandardFont.TimesItalic, 12);
      canvas.DrawString("The standard font.", standardFont, brush, 10, 90);
 
      PDFFont fontFromFile = PDFFont.FromFile("..\\..\\symbol.ttf", 12);
      canvas.DrawString("Font from file.", fontFromFile, brush, 10, 120);
 
      document.Save("Fonts.pdf", true);
    }
  }
}

 

Visial Basic.NET :

Imports PDFMosaic
Imports System.Drawing
 
Module Fonts
  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 systemFont As New PDFFont("Arial", 12)
    canvas.DrawString("The system font.", systemFont, brush, 10, 60)
 
    Dim standardFont As New PDFFont(PDFStandardFont.TimesItalic, 12)
    canvas.DrawString("The standard font.", standardFont, brush, 10, 90)
 
    Dim fontFromFile = PDFFont.FromFile("..\\..\\symbol.ttf", 12)
    canvas.DrawString("Font from file.", fontFromFile, brush, 10, 120)
 
    document.Save("Fonts.pdf", True)
  End Sub
End Module

 


Home       Features       Download       License       Tutorial       Version History       Source Code