public static void TestPDFGraphics(string pdfFileName)
{
// create new PDF document
Vintasoft.Imaging.Pdf.PdfDocument document =
new Vintasoft.Imaging.Pdf.PdfDocument();
// add new page
document.Pages.Add(new System.Drawing.SizeF(1000, 1000));
// get graphics object associated with page
using (Vintasoft.Imaging.Pdf.Drawing.PdfGraphics graphics = document.Pages[0].GetGraphics())
{
// draw primitives
Vintasoft.Imaging.Pdf.Drawing.PdfPen pen =
new Vintasoft.Imaging.Pdf.Drawing.PdfPen(System.Drawing.Color.Red);
pen.Width = 3;
Vintasoft.Imaging.Pdf.Drawing.PdfBrush brush =
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;
Vintasoft.Imaging.Drawing.IDrawingFont font = Vintasoft.Imaging.Drawing.DrawingFactory.Default.CreateGenericSansSerifFont(30);
graphics.DrawString("Vector string", font, brush, new System.Drawing.PointF(100, 500));
Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont 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));
}
// get graphics object associated with page
using (Vintasoft.Imaging.Pdf.Drawing.PdfGraphics graphics = document.Pages[0].GetGraphics())
{
// draw rendered page image (500x500 pixels) onto page
using (Vintasoft.Imaging.VintasoftImage img = document.Pages[0].Render(500, 500))
graphics.DrawImage(img, new System.Drawing.RectangleF(600, 0, 300, 300));
}
// save document
document.SaveChanges(pdfFileName);
// close document
document.Dispose();
}
Forum 'Code samples'
Code samples for VintaSoft PDF .NET Plug-in. Here you can request a code sample.
Board index < VintaSoft Imaging < VintaSoft PDF .NET Plug-in Discussions < Code samples
