Here is i am generated pdf code based on the order numbers,when save time only one order pdf document is stored,remaining orders are not save.In my Invoiceorders table i have 600 rows,how to save file order by order.
- protected void btnPDF_Click(object sender, EventArgs e)
- {
- clsDBFunctions objDBFunc = new clsDBFunctions();
- clsError objError = new clsError();
- using (OracleConnection conn = objDBFunc.GetODPConnection(ref objError))
- {
- OracleDataAdapter thisAdapter = new OracleDataAdapter("select * from ORD_NUMBER ", conn);
- DataSet DataSet = new DataSet();
- thisAdapter.Fill(DataSet, "ORD_NUMBER");
-
-
- for (int i = 0; i <= DataSet.Tables["ORD_NUMBER"].Rows.Count - 1; i++)
- {
- mStream = new MemoryStream();
- pdfDoc = new Document(PageSize.A4);
- writerPdf = PdfWriter.GetInstance(pdfDoc, mStream);
- pdfDoc.SetPageSize(new iTextSharp.text.Rectangle(800f, 560f));
- writerPdf.ViewerPreferences = PdfWriter.PageModeUseOutlines;
- HeaderFooter PageEventFooter = new HeaderFooter();
- PageEventFooter.StrCompid = strCompId;
- PageEventFooter.StrSiteid = strSiteId;
- PageEventFooter.StrOrderno = DataSet.Tables[0].Rows[i]["ORDERNO"].ToString();
- writerPdf.PageEvent = PageEventFooter;
- ClsPageNumberCh PageEventHandler = new ClsPageNumberCh();
- writerPdf.PageEvent = PageEventHandler;
- pdfDoc.Open();
- string OrdNo = DataSet.Tables[0].Rows[i]["ORDERNO"].ToString();
- BindPDFDetail(OrdNo);
- BindPDFCarrier(OrdNo);
- BindPDFItem(OrdNo);
- BindPDFRemarksDetail(OrdNo);
- BindPageParagraph();
- pdfDoc.Close();
- byte[] bytes = mStream.ToArray();
- mStream.Close();
- string pdfPath = ConfigurationManager.AppSettings["pdfPath"].ToString() + "Invoice_Orders.pdf";
- File.WriteAllBytes(pdfPath, mStream.ToArray());
- }