Document doc = new Document(); // Open window where the pdf report file will be saved SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Arquivo PDF (.pdf)| *.pdf"; // restrict the file format to save, and set the extension as .pdf saveFileDialog.Title = "Selecione aonde deseja salvar o arquivo"; // checkbox title that opens saveFileDialog.ShowDialog(); // open the check box PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(saveFileDialog.FileName, FileMode.Create)); // Open document doc.Open(); // Parameter creation to create the header Paragraph paragrafo1 = new Paragraph(Font.BOLD); paragrafo1.Add("Cliente "); paragrafo1.Add("Livro "); paragrafo1.Add("Date de Empréstimo "); paragrafo1.Add("Data de Devolução "); paragrafo1.Add("Status "); paragrafo1.Add("Multa "); // adding header doc.Add(paragrafo1); // Creating pdfTable PdfPTable pdfTable = new PdfPTable(5); foreach (DataGridViewRow row in dataGrid.Rows) { // Populated pdfTable with information from the current row of the dataGrid passed as parameter pdfTable.Rows.Add(row.DataBoundItem.ToString()); // Creating new paragraph Paragraph paragrafo = new Paragraph(); // Adding PDFTable Line to Paragraph paragrafo.AddAll(pdfTable.Rows.ToArray()); // Adding paragraph to document doc.Add(paragrafo); } // Closing the document doc.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)