Although it is true that you cannot use JAVA2D with iTextSharp, you can still draw vector graphics in native PDF format by directly writing the PdfWriter.DirectContent object. It supports all the standard methods MoveTo() , LineTo() , CurveTo() , etc. that you would expect from a vector drawing program. Below, the full-featured VB.Net WinForms application focused on iTextSharp 5.1.1.0 demonstrates some simple applications.
Option Explicit On Option Strict On Imports iTextSharp.text Imports iTextSharp.text.pdf Imports System.IO Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim OutputFile As String = Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "VectorTest.pdf") Using FS As New FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None) Using Doc As New Document(PageSize.LETTER) Using writer = PdfWriter.GetInstance(Doc, FS) ''//Open the PDF for writing Doc.Open() Dim cb As PdfContentByte = writer.DirectContent ''//Save the current state so that we can restore it later. This is not required but it makes it easier to undo things later cb.SaveState() ''//Draw a line with a bunch of options set cb.MoveTo(100, 100) cb.LineTo(500, 500) cb.SetRGBColorStroke(255, 0, 0) cb.SetLineWidth(5) cb.SetLineDash(10, 10, 20) cb.SetLineCap(PdfContentByte.LINE_CAP_ROUND) cb.Stroke() ''//This undoes any of the colors, widths, etc that we did since the last SaveState cb.RestoreState() ''//Draw a circle cb.SaveState() cb.Circle(200, 500, 50) cb.SetRGBColorStroke(0, 255, 0) cb.Stroke() ''//Draw a bezier curve cb.RestoreState() cb.MoveTo(100, 300) cb.CurveTo(140, 160, 300, 300) cb.SetRGBColorStroke(0, 0, 255) cb.Stroke() ''//Close the PDF Doc.Close() End Using End Using End Using End Sub End Class
EDIT
By the way, although you cannot use JAVA2D (which is obviously Java and does not work with .Net), you can create iTextSharp images using the standard System.Drawing.Image class and pass it to the static method iTextSharp.text.Image.GetInstance() . Unfortunately, System.Drawing.Image is a raster / raster object, so this will not help you in this case.
source share