Click here to Skip to main content
15,890,825 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can i use instead of Sleep() method? Pin
sugarpasa9-Feb-16 6:12
sugarpasa9-Feb-16 6:12 
GeneralRe: How can i use instead of Sleep() method? Pin
Richard Andrew x649-Feb-16 6:19
professionalRichard Andrew x649-Feb-16 6:19 
QuestionScanning QR code Pin
Member 123142768-Feb-16 7:13
Member 123142768-Feb-16 7:13 
AnswerRe: Scanning QR code Pin
OriginalGriff8-Feb-16 8:09
mveOriginalGriff8-Feb-16 8:09 
AnswerRe: Scanning QR code Pin
Sascha Lefèvre8-Feb-16 8:15
professionalSascha Lefèvre8-Feb-16 8:15 
QuestionC# iTexSharp How to put PDF page number during creation PDF File Pin
Zefir18-Feb-16 2:38
Zefir18-Feb-16 2:38 
AnswerRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Richard MacCutchan8-Feb-16 3:17
mveRichard MacCutchan8-Feb-16 3:17 
GeneralRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Zefir18-Feb-16 3:27
Zefir18-Feb-16 3:27 
Yes but I'm beginner of C# and I use Windows forms.

I would like to add page nr to this cede:

private void Table_From_DB_Click(object sender, EventArgs e)
{

iTextSharp.text.Font fontTitle = FontFactory.GetFont("Arial", 18, iTextSharp.text.Font.BOLD, BaseColor.RED);

iTextSharp.text.Font fontTable = FontFactory.GetFont("Arial", 5, iTextSharp.text.Font.NORMAL, BaseColor.RED);
string FileName = textBox1.Text;

Document doc = new Document(iTextSharp.text.PageSize.A4, 10, 10, 42, 35); // tak

PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(FileName + ".pdf", FileMode.Create));

string Fn;
Fn = Path.GetFileName(FileName + ".pdf");
MessageBox.Show("Plik zapisano jako: " + Fn);
doc.Open();


PdfPTable table = new PdfPTable(4);

//actual width of table in points

table.TotalWidth = 530f;

//fix the absolute width of the table

table.LockedWidth = true;

//relative col widths in proportions - 1/3 and 2/3

float[] widths = new float[] { 1f, 1f, 1f, 1f };

table.SetWidths(widths);

table.HorizontalAlignment = 0;

//leave a gap before and after the table

table.SpacingBefore = 20f;

table.SpacingAfter = 30f;
PdfPCell cell = new PdfPCell(new Phrase("Products"));

cell.Colspan = 4;

cell.Border = 0;

cell.HorizontalAlignment = 1;

table.AddCell(cell);

// SqlDataReader reader;
string connect = @"Data Source=RZW-L-PB72GX3\SQLEXPRESS;Initial Catalog=StepSample;Integrated Security=True";


using (SqlConnection conn = new SqlConnection(connect))
{

string query = "SELECT [ID],[FullName],[Admitted],[Capital] FROM [StepSample].[dbo].[StateRegion] WHERE [ID]<90";
SqlCommand cmd = new SqlCommand(query, conn);
try
{

conn.Open();

using (SqlDataReader rdr = cmd.ExecuteReader())
{

while (rdr.Read())
{

table.AddCell(rdr[0].ToString());

table.AddCell(rdr[1].ToString());
table.AddCell(rdr[2].ToString());
table.AddCell(rdr[3].ToString());

}

}

}

catch (Exception ex)
{

Console.WriteLine(ex.Message);


}

doc.Add(table);
doc.Close();
}
}
GeneralRe: C# iTexSharp How to put PDF page number during creation PDF File Pin
Richard MacCutchan8-Feb-16 3:50
mveRichard MacCutchan8-Feb-16 3:50 
QuestionIs this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 21:07
Member 120616007-Feb-16 21:07 
AnswerRe: Is this serial port class and how I use it thred safe? Pin
Daniel Pfeffer7-Feb-16 21:29
professionalDaniel Pfeffer7-Feb-16 21:29 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 21:41
Member 120616007-Feb-16 21:41 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Daniel Pfeffer7-Feb-16 22:10
professionalDaniel Pfeffer7-Feb-16 22:10 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 22:13
Member 120616007-Feb-16 22:13 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616008-Feb-16 0:11
Member 120616008-Feb-16 0:11 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Daniel Pfeffer8-Feb-16 2:07
professionalDaniel Pfeffer8-Feb-16 2:07 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616008-Feb-16 2:10
Member 120616008-Feb-16 2:10 
AnswerRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 21:47
professionalJochen Arndt7-Feb-16 21:47 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 21:52
Member 120616007-Feb-16 21:52 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 22:09
professionalJochen Arndt7-Feb-16 22:09 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 22:13
Member 120616007-Feb-16 22:13 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 22:36
professionalJochen Arndt7-Feb-16 22:36 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 23:26
Member 120616007-Feb-16 23:26 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Jochen Arndt7-Feb-16 23:35
professionalJochen Arndt7-Feb-16 23:35 
GeneralRe: Is this serial port class and how I use it thred safe? Pin
Member 120616007-Feb-16 23:59
Member 120616007-Feb-16 23:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.