How to draw circle in PDF document using ByteScout PDF SDK - ByteScout

How to draw circle in PDF document using ByteScout PDF SDK

  • Home
  • /
  • Articles
  • /
  • How to draw circle in PDF document using ByteScout PDF SDK

Drawing a circle in PDF document
This example demonstrates how to draw a circle object using Drawing class in ByteScout PDF SDK
Circle in PDF document made with ByteScout PDF SDK

Program.vb:
VB

'*******************************************************************
'       ByteScout PDF SDK
'                                                                   
'       Copyright © 2016 Bytescout, https://bytescout.com        
'       ALL RIGHTS RESERVED                                         
'                                                                   
'*******************************************************************

Imports Bytescout.PDF

''' <summary>
''' This example demonstrates how to draw lines and curves.
''' </summary>
Class Program

    Shared Sub Main()

        ' Create new document
        Dim pdfDocument = New Document()
        pdfDocument.RegistrationName = "demo"
		pdfDocument.RegistrationKey = "demo"
        ' Add page
        Dim page = New Page(PaperFormat.A4)
        pdfDocument.Pages.Add(page)

        Dim canvas = page.Canvas

        Dim solidPen = New SolidPen()
        Dim dashedPen = New SolidPen()
        dashedPen.DashPattern = New DashPattern(New Single() {2, 2})

        ' Draw dashed lines
        canvas.DrawLine(dashedPen, 100, 100, 200, 100)
        canvas.DrawLine(dashedPen, 200, 100, 200, 200)
        canvas.DrawLine(dashedPen, 200, 200, 100, 200)
        ' Draw besier curve by the same points
        canvas.DrawCurve(solidPen, 100, 100, 200, 100, 200, 200, 100, 200)

        ' Save document to file
        pdfDocument.Save("result.pdf")

        ' Cleanup 
		pdfDocument.Dispose()

        ' Open document in default PDF viewer app
        Process.Start("result.pdf")

    End Sub

End Class 

Program.cs:
C#

 //*******************************************************************
//       ByteScout PDF SDK		                                     
//                                                                   
//       Copyright © 2016 ByteScout - https://bytescout.com       
//       ALL RIGHTS RESERVED                                         
//                                                                   
//*******************************************************************

using System.Diagnostics;
using Bytescout.PDF;

namespace LinesAndCurves
{
	/// <summary>
	/// This example demonstrates how to draw lines and curves.
	/// </summary>
	class Program
	{
		static void Main()
		{
			// Create new document
			Document pdfDocument = new Document();
			pdfDocument.RegistrationName = "demo";
			pdfDocument.RegistrationKey = "demo";
			// Add page
			Page page = new Page(PaperFormat.A4);
			pdfDocument.Pages.Add(page);

			Canvas canvas = page.Canvas;

			SolidPen solidPen = new SolidPen();
			SolidPen dashedPen = new SolidPen();
			dashedPen.DashPattern = new DashPattern(new float[] { 2, 2 });

			// Draw dashed lines
			canvas.DrawLine(dashedPen, 100, 100, 200, 100);
			canvas.DrawLine(dashedPen, 200, 100, 200, 200);
			canvas.DrawLine(dashedPen, 200, 200, 100, 200);
			// Draw besier curve by the same points
			canvas.DrawCurve(solidPen, 100, 100, 200, 100, 200, 200, 100, 200);
			
			// Save document to file
			pdfDocument.Save("result.pdf");

			// Cleanup 
			pdfDocument.Dispose();

			// Open document in default PDF viewer app
			Process.Start("result.pdf");
		}
	}
}

Tutorials:

prev
next