PDF Mosaic: How to create graphics in PDF document using patterns


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

 

This sample shows how to use colored and uncolored tiling patterns.

How to use colored and uncolored tiling patterns in PDF Mosaic
 

C# :

using PDFMosaic;
using System.Drawing;
 
namespace Patterns
{
  class Patterns
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
      PDFCanvas canvas = document.Pages[0].Canvas;
 
      PDFColorRGB red = new PDFColorRGB(255, 0, 0);
      PDFColorRGB green = new PDFColorRGB(0, 255, 0);
      PDFColorRGB blue = new PDFColorRGB(0, 0, 255);
      PDFSolidPen pen = new PDFSolidPen();
 
      PDFColoredTilingBrush tillingbrush = new PDFColoredTilingBrush(50, 50);
      PDFUncoloredTilingBrush untillingbrush = new PDFUncoloredTilingBrush(10, 10);
      canvas = untillingbrush.Canvas;
      canvas.DrawCircle(new PDFSolidPen(green), new PDFSolidBrush(blue), 5, 5, 4);
      untillingbrush.Color = green;
      canvas = tillingbrush.Canvas;
      canvas.DrawEllipse(pen, untillingbrush, 0, 0, 49, 25);
      canvas.RotateTransform(45);
      canvas.DrawRectangle(new PDFSolidBrush(new PDFColorRGB(100, 100, 100)), 33, 5, 10, 20);
      canvas = document.Pages[0].Canvas;
      canvas.DrawRoundedRectangle(pen, tillingbrush, 100, 100, 200, 300, 30);
 
      document.Save("Patterns.pdf", true);
    }
  }
}

 

Visial Basic.NET :

Imports PDFMosaic
Imports System.Drawing
 
Module Patterns
  Sub Main()
    Dim document As PDFDocument = New PDFDocument()
    document.Pages.Add(New PDFPage(PDFPaperFormat.A4))
    Dim canvas As PDFCanvas = document.Pages(0).Canvas
 
    Dim red As PDFColorRGB = New PDFColorRGB(255, 0, 0)
    Dim green As PDFColorRGB = New PDFColorRGB(0, 255, 0)
    Dim blue As PDFColorRGB = New PDFColorRGB(0, 0, 255)
    Dim pen As PDFSolidPen = New PDFSolidPen()
 
    Dim tillingbrush As PDFColoredTilingBrush = New PDFColoredTilingBrush(50, 50)
    Dim untillingbrush As PDFUncoloredTilingBrush = New PDFUncoloredTilingBrush(10, 10)
    canvas = untillingbrush.Canvas
    canvas.DrawCircle(New PDFSolidPen(green), New PDFSolidBrush(blue), 5, 5, 4)
    untillingbrush.Color = green
    canvas = tillingbrush.Canvas
    canvas.DrawEllipse(pen, untillingbrush, 0, 0, 49, 25)
    canvas.RotateTransform(45)
    canvas.DrawRectangle(New PDFSolidBrush(New PDFColorRGB(100, 100, 100)), 33, 5, 10, 20)
    canvas = document.Pages(0).Canvas
    canvas.DrawRoundedRectangle(pen, tillingbrush, 100, 100, 200, 300, 30)
 
    document.Save("Patterns.pdf", True)
  End Sub
End Module

 


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