Create Business Card

PDF Drawing Text Write Filesystem

Creates business card in PDF format.

Сode Snippet

using (var writer = new PdfWriter("CreateBusinessCard.pdf"))
{
    int width = 350;
    int height = 200;

    using (var graphics = writer.GetGraphics())
    {
        // Front side
        writer.AddPage(width, height, RgbColor.White);

        var blueBrush = new SolidBrush(RgbColor.DeepSkyBlue);

        // Draw circle
        graphics.DrawEllipse(new Pen(RgbColor.DeepSkyBlue, 2f), 15f, 20f, 30f, 30f);

        // Draw text
        var font = graphics.CreateFont("Arial", 18f);
        var text = new PlainText("Front side", font, new SolidBrush(RgbColor.Gray), 95f, 41f, TextAlignment.Center);
        graphics.DrawText(text);

        font = graphics.CreateFont("Arial", 16f);
        text = new PlainText("<span>John Doe</span><br/><span style='color:gray;font-size:16pt'>General Manager</span>", font, blueBrush, 335f, 100f, TextAlignment.Right);

        graphics.DrawText(text);

        graphics.FillRectangle(blueBrush, 0, height - 50, width, 50);

        font = graphics.CreateFont("Arial", 12f);
        text = new PlainText(@"<span>123.456.7890</span><br/><span>info@website.com</span>", font, new SolidBrush(RgbColor.White), 15f, 170f, TextAlignment.Left);

        graphics.DrawText(text);

        text = new PlainText("<span>335 Cloverfield Blvd</span><br/><span>Charlington, NY 10123</span>", font, new SolidBrush(RgbColor.White), 200f, 170f, TextAlignment.Left);

        graphics.DrawText(text);

        // Back side
        writer.AddPage(width, height, RgbColor.DeepSkyBlue);

        graphics.DrawEllipse(new Pen(RgbColor.White, 3f), 65f, 72f, 55f, 55f);

        font = graphics.CreateFont("Arial", 36);

        text = new PlainText("Back side", font, new SolidBrush(RgbColor.White), 140f, 112f, TextAlignment.Left);
        graphics.DrawText(text);
    }
}

Output

CreateBusinessCard.pdf

Download

CreateBusinessCard.png

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog