Click here to Skip to main content
15,919,893 members

Comments by Member 11821221 (Top 2 by date)

Member 11821221 13-Aug-15 1:46am View    
Deleted
This is my code ...

FileStream fs = new FileStream("abc.pdf", FileMode.Create, FileAccess.Write, FileShare.None);
Document doc = new Document(iTextSharp.text.PageSize.A4, 36, 36, 63, 10); //left ,right,top,bottom
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.Open();

string strDSN = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\diy.mdb";
string strSQL = "SELECT * FROM project where ID='" + dbProjID + "'";
OleDbConnection myConn = new OleDbConnection(strDSN);
OleDbDataAdapter myCmd = new OleDbDataAdapter(strSQL, myConn);
myConn.Open();

DataSet dtSet = new DataSet();
myCmd.Fill(dtSet, "Developer");
DataTable dTable = dtSet.Tables[0];


// Now start putting content into the PDF file created

//***************************ADDING TABLE IN PDF FILE *********************************
//add first cell

PdfPTable table = new PdfPTable(2);
table.WidthPercentage = 98;
table.SpacingBefore = 20f;


//table.PaddingTop=

PdfPCell cell = new PdfPCell(new Phrase("Customer Information"));
cell.BackgroundColor = new BaseColor(0, 0, 250);
cell.Colspan = 2;
cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right (for heading allignment)
table.AddCell(cell);


foreach (DataRow dtRow in dTable.Rows)
{


table.AddCell (dtRow.Table.ToString());
// table.AddCell(dtRow[i].ToString());

}
doc.Add(table);
myConn.Close();
doc.Close();
Member 11821221 10-Aug-15 3:20am View    
Thank you .......