Veri tabanındaki bilgileri tablo olarak pdf’ye aktar — Csharp

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;//www.gorselprogramlama.com
using System.Windows.Forms;
using iTextSharp.text.pdf;
using iTextSharp.text;
using System.IO;
using System.Data.OleDb;
using System.Drawing.Text;
namespace pdf_aktar
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnVeri_Click(object sender, EventArgs e)
{
OleDbConnection bag = new OleDbConnection("Provider=Microsoft.Ace.Oledb.12.0;Data Source=data.accdb");
iTextSharp.text.Document document = new iTextSharp.text.Document();
PdfWriter.GetInstance(document, new FileStream(@"C:\gorsel.pdf", FileMode.Create));
PdfPTable table = new PdfPTable(2);
//
table.TotalWidth = 216f;
//tablonun mutlak genişliği
table.LockedWidth = true;
//Göreceli kolon genişiği
float[] widths = new float[] { 1f, 2f };
table.SetWidths(widths);
table.HorizontalAlignment = 0;
//Tabloda boşluk bırak
table.SpacingBefore = 20f;
table.SpacingAfter = 30f;
//www.gorselprogramlama.com
PdfPCell cell = new PdfPCell(new Phrase("ILLER"));
cell.Colspan = 2;
cell.Border = 0;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
string query = "SELECT plaka,ilAdi FROM iller";
OleDbCommand kmt = new OleDbCommand(query, bag);
bag.Open();
OleDbDataReader oku;//www.gorselprogramlama.com
oku = kmt.ExecuteReader();
while (oku.Read())
{
table.AddCell(oku[0].ToString());
table.AddCell(oku[1].ToString());
}
bag.Close();
document.Open();
document.Add(table);
document.Close();
}
}//www.gorselprogramlama.com
}
[/code]


