PDF Mosaic: How to create graphics templates and use them


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

 

This sample shows how to create and use graphics templates in PDF Mosaic library.

How to create and use graphics templates in PDF Mosaic library
 

C# :

using PDFMosaic;
using System;
 
namespace Template
{
  class Template
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      PDFGraphicsTemplate template = new PDFGraphicsTemplate(500, 800);
 
      PDFFont font = new PDFFont(PDFStandardFont.Helvetica, 16);
      PDFSolidBrush brush = new PDFSolidBrush(new PDFColorRGB(255, 0, 0));
 
      template.DrawRectangle(brush, 100, 50, 300, 30);
      brush.Color = new PDFColorRGB(0, 0, 0);
      template.DrawString("Template", font, brush, 200, 55);
 
      for (int i = 0; i < 2; ++i)
      {
        PDFPage page = new PDFPage(PDFPaperFormat.A4);
        page.Canvas.DrawTemplate(template, 0, 0);
        document.Pages.Add(page);
      }
 
      document.Save("Template.pdf", true);
    }
  }
}

 

Visial Basic.NET :

Imports PDFMosaic
Imports System
 
Module Template
  Sub Main()
    Dim document As New PDFDocument()
    Dim template As New PDFGraphicsTemplate(500, 800)
 
    Dim font As New PDFFont(PDFStandardFont.Helvetica, 16)
    Dim brush As New PDFSolidBrush(New PDFColorRGB(255, 0, 0))
 
    template.DrawRectangle(brush, 100, 50, 300, 30)
    brush.Color = New PDFColorRGB(0, 0, 0)
    template.DrawString("Template", font, brush, 200, 55)
 
    For i As Single = 0 To 1
      Dim page As New PDFPage(PDFPaperFormat.A4)
      page.Canvas.DrawTemplate(template, 0, 0)
      document.Pages.Add(page)
    Next
 
    document.Save("Template.pdf", True)
  End Sub
End Module

 


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