C# Business Card PDF Creator with iTextSharp
Learn to create business card PDFs in C# using iTextSharp. Tutorial includes credits to LeonidasGFX. Comment your email for transfer info. 📄

Shaun Roos
1.4K views • Sep 1, 2017

About this video
C# Business Card PDF Creator Application
iTextSharp Tutorial
Credit for intro video to : LeonidasGFX
Comment your email address if you want me to wetransfer you the complete visual studio project.
Please like the video and subscribe to the channel.
Much Love.
Code for the Save PDF Button:
using (SaveFileDialog sfd = new SaveFileDialog() { FileName = textBox1.Text + ".pdf", ValidateNames = true })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
iTextSharp.text.Rectangle businessCard = new iTextSharp.text.Rectangle(255.118f, 141.732f);
Document doc = new Document();
doc.SetMargins(13.3f, 0, 8f, 0);
doc.SetPageSize(businessCard);
iTextSharp.text.Font font_01 = FontFactory.GetFont("C\\Windows\\Fonts\\BEBAS__.ttf", 14, BaseColor.WHITE);
iTextSharp.text.Font font_02 = FontFactory.GetFont("C\\Windows\\Fonts\\BEBAS__.ttf", 8, BaseColor.WHITE);
Chunk c01 = new Chunk(textBox1.Text, font_01);
Chunk c02 = new Chunk(textBox2.Text, font_02);
Chunk c03 = new Chunk(textBox3.Text, font_01);
Chunk c04 = new Chunk(textBox4.Text, font_02);
Paragraph p01 = new Paragraph();
p01.Add(c01);
Paragraph p02 = new Paragraph();
p02.Add(c02);
p02.SpacingBefore = 1;
Paragraph p03 = new Paragraph();
p03.Add(c03);
p03.SpacingBefore = 50;
p03.IndentationLeft = 130;
Paragraph p04 = new Paragraph();
p04.Add(c04);
p04.SpacingBefore = 1;
p04.IndentationLeft = 130;
iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance("Background.jpg");
logo.Alignment = iTextSharp.text.Image.UNDERLYING;
logo.ScaleAbsolute(255.118f, 141.732f);
logo.SetAbsolutePosition(0, 0);
try
{
PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create));
doc.Open();
doc.Add(logo);
doc.Add(p01);
doc.Add(p02);
doc.Add(p03);
doc.Add(p04);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
doc.Close();
}
}
}
iTextSharp Tutorial
Credit for intro video to : LeonidasGFX
Comment your email address if you want me to wetransfer you the complete visual studio project.
Please like the video and subscribe to the channel.
Much Love.
Code for the Save PDF Button:
using (SaveFileDialog sfd = new SaveFileDialog() { FileName = textBox1.Text + ".pdf", ValidateNames = true })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
iTextSharp.text.Rectangle businessCard = new iTextSharp.text.Rectangle(255.118f, 141.732f);
Document doc = new Document();
doc.SetMargins(13.3f, 0, 8f, 0);
doc.SetPageSize(businessCard);
iTextSharp.text.Font font_01 = FontFactory.GetFont("C\\Windows\\Fonts\\BEBAS__.ttf", 14, BaseColor.WHITE);
iTextSharp.text.Font font_02 = FontFactory.GetFont("C\\Windows\\Fonts\\BEBAS__.ttf", 8, BaseColor.WHITE);
Chunk c01 = new Chunk(textBox1.Text, font_01);
Chunk c02 = new Chunk(textBox2.Text, font_02);
Chunk c03 = new Chunk(textBox3.Text, font_01);
Chunk c04 = new Chunk(textBox4.Text, font_02);
Paragraph p01 = new Paragraph();
p01.Add(c01);
Paragraph p02 = new Paragraph();
p02.Add(c02);
p02.SpacingBefore = 1;
Paragraph p03 = new Paragraph();
p03.Add(c03);
p03.SpacingBefore = 50;
p03.IndentationLeft = 130;
Paragraph p04 = new Paragraph();
p04.Add(c04);
p04.SpacingBefore = 1;
p04.IndentationLeft = 130;
iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance("Background.jpg");
logo.Alignment = iTextSharp.text.Image.UNDERLYING;
logo.ScaleAbsolute(255.118f, 141.732f);
logo.SetAbsolutePosition(0, 0);
try
{
PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create));
doc.Open();
doc.Add(logo);
doc.Add(p01);
doc.Add(p02);
doc.Add(p03);
doc.Add(p04);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
doc.Close();
}
}
}
Tags and Topics
Browse our collection to discover more content in these categories.
Video Information
Views
1.4K
Likes
12
Duration
10:05
Published
Sep 1, 2017
User Reviews
4.1
(1)