Public Shared Sub TestPDFGraphics(pdfFileName As String)
' create new PDF document
Dim document As New Vintasoft.Imaging.Pdf.PdfDocument()
' add new page
document.Pages.Add(New System.Drawing.SizeF(1000, 1000))
' get graphics object associated with page
Using graphics As Vintasoft.Imaging.Pdf.Drawing.PdfGraphics = document.Pages(0).GetGraphics()
' draw primitives
Dim pen As New Vintasoft.Imaging.Pdf.Drawing.PdfPen(System.Drawing.Color.Red)
pen.Width = 3
Dim brush As New Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Green)
graphics.DrawLine(pen, 0, 0, 50, 150)
graphics.DrawCurve(pen, 50, 150, 100, 200, 200, _
20, 300, 150)
pen.Color = System.Drawing.Color.Blue
graphics.DrawEllipse(pen, 400, 400, 200, 300)
graphics.FillEllipse(brush, 500, 500, 70, 150)
brush.Color = System.Drawing.Color.FromArgb(127, System.Drawing.Color.Red)
graphics.FillRectangle(brush, 450, 550, 300, 300)
pen.Width = 10
graphics.DrawRectangle(pen, 0, 0, 1000, 1000)
' draw vector string
brush.Color = System.Drawing.Color.Green
Dim font As Vintasoft.Imaging.Drawing.IDrawingFont = Vintasoft.Imaging.Drawing.DrawingFactory.[Default].CreateGenericSansSerifFont(30)
graphics.DrawString("Vector string", font, brush, New System.Drawing.PointF(100, 500))
Dim pdfFont As Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont = document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman)
' draw text string
graphics.DrawString("Text string", pdfFont, 30, brush, New System.Drawing.PointF(100, 600))
End Using
' get graphics object associated with page
Using graphics As Vintasoft.Imaging.Pdf.Drawing.PdfGraphics = document.Pages(0).GetGraphics()
' draw rendered page image (500x500 pixels) onto page
Using img As Vintasoft.Imaging.VintasoftImage = document.Pages(0).Render(500, 500)
graphics.DrawImage(img, New System.Drawing.RectangleF(600, 0, 300, 300))
End Using
End Using
' save document
document.SaveChanges(pdfFileName)
' close document
document.Dispose()
End Sub