Jump to content

como colocar data e hora do sistema num pdf com itextsharp


Recommended Posts

Posted (edited)

boas 🙂

como indica o titulo e isso que eu pretendo...

aqui esta o meu codigo de pdf

FileStream tix = new FileStream("Relatório.pdf", FileMode.Create);

Document documento = new Document(PageSize.A4, 25, 25, 30, 30);

PdfWriter escrever = PdfWriter.GetInstance(documento, tix);

documento.Open();

PdfPTable tabela = new PdfPTable(dataGridView1.Columns.Count);

//add the headers from DGV to the table

for (int j = 0; j < dataGridView1.Columns.Count; j++)

{

tabela.AddCell(new Phrase(dataGridView1.Columns[j].HeaderText));

}

//flag the first row as a header

tabela.HeaderRows = 1;

//add the actual rows from the DGV to the table

for (int i = 0; i < dataGridView1.Rows.Count; i++)

{

for (int k = 0; k <dataGridView1.Columns.Count;k++)

{

if(dataGridView1[k,i].Value != null)

{

tabela.AddCell(new Phrase(dataGridView1[k, i].Value.ToString()));

}

}

}

documento.Add(tabela);

documento.Close();

Edited by Pipo01

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.