Pdfwriter itextsharp mulitple pages4/7/2023 ![]() ![]() Response.AddHeader("content-disposition", "attachment filename=GridViewExport. Response.ContentType = "application/pdf" StringReader sr = new StringReader(sw.ToString()) PdfDoc.SetPageSize(new Rectangle(600, 300)) Using (HtmlTextWriter hw = new HtmlTextWriter(sw)) Using (StringWriter sw = new StringWriter()) PdfWriter.GetInstance(pdfDoc, Response.OutputStream) įor (int i = 1 i <= GridView1.PageCount i++) HTMLWorker htmlparser = new HTMLWorker(pdfDoc) Protected void ExportToPDF(object sender, EventArgs e)ĭocument pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f) Protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e) Using (SqlDataAdapter sda = new SqlDataAdapter()) Using (SqlCommand cmd = new SqlCommand("SELECT * FROM Customers")) Using (SqlConnection con = new SqlConnection(strConnString)) I have created a sample using GridView and Northwind Database which adds GridView to multiple pages in documentĬode protected void Page_Load(object sender, EventArgs e) Mm.Attachments.Add(new Attachment(new MemoryStream(bytes), "OnSiteWork.pdf")) MailMessage mm = new MailMessage("email", txt_To.Text) Phrase = new Phrase(new Chunk(dr + " " + " " + " " + " " + " " + "Matic Comm No: " + dr, FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK))) Ĭell = PhraseCell(new Phrase(), PdfPCell.ALIGN_CENTER) This indirect object capability saves space in PDF files by allowing objects such as fonts to be referenced from multiple pages, and also allows PDF files. Table.AddCell(PhraseCell(new Phrase("Comm No: ", FontFactory.GetFont("Arial", 10, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT)) Table.AddCell(PhraseCell(phrase, PdfPCell.ALIGN_LEFT)) Ĭell = PhraseCell(new Phrase(), PdfPCell.ALIGN_LEFT) Phrase = new Phrase(new Chunk(dr + " " + "Drive: " + dr + " " + " " + "Matic Type: " + dr + " " + "Control: " + dr, FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK))) Table.AddCell(PhraseCell(new Phrase("Actuator Type: ", FontFactory.GetFont("Arial", 10, BaseColor.BLACK)), PdfPCell.ALIGN_LEFT)) Table.HorizontalAlignment = Element.ALIGN_RIGHT PdfWriter writer = PdfWriter.GetInstance(document, memoryStream) Using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) Protected void GenerateReport(object sender, EventArgs e)ĭataRow dr = GetData("SELECT * FROM OnSiteWorkTx where DocID = " + ).Rows ĭocument document = new Document(PageSize.A4, 88f, 88f, 10f, 10f) įont NormalFont = FontFactory.GetFont("Arial", 12, Font.NORMAL, BaseColor.BLACK) I would like iTextsharp to loop and create a new page based on this page number and have one pdf doc. ![]() Hello, I am creating a pdf document with fields from sql database using iTextsharp,after a client inputs information, the next button is pressed each page is saved in new row with page01,page02 etc as a column within that database. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |