How Save Many PDF file in the Same Physical path

Dec 21 2017 7:41 AM
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.
  1. protected void btnPDF_Click(object sender, EventArgs e)  
  2. {  
  3. clsDBFunctions objDBFunc = new clsDBFunctions();  
  4. clsError objError = new clsError();  
  5. using (OracleConnection conn = objDBFunc.GetODPConnection(ref objError))  
  6. {  
  7. OracleDataAdapter thisAdapter = new OracleDataAdapter("select * from ORD_NUMBER ", conn);  
  8. DataSet DataSet = new DataSet();  
  9. thisAdapter.Fill(DataSet, "ORD_NUMBER");  
  10. //foreach (DataRow theRow in DataSet.Tables["ORD_NUMBER"].Rows)  
  11. //{  
  12. for (int i = 0; i <= DataSet.Tables["ORD_NUMBER"].Rows.Count - 1; i++)  
  13. {  
  14. mStream = new MemoryStream();  
  15. pdfDoc = new Document(PageSize.A4);// public Document(Rectangle pageSize, float marginLeft, float marginRight, float marginTop, float marginBottom);  
  16. writerPdf = PdfWriter.GetInstance(pdfDoc, mStream);  
  17. pdfDoc.SetPageSize(new iTextSharp.text.Rectangle(800f, 560f));  
  18. writerPdf.ViewerPreferences = PdfWriter.PageModeUseOutlines;  
  19. HeaderFooter PageEventFooter = new HeaderFooter();  
  20. PageEventFooter.StrCompid = strCompId;  
  21. PageEventFooter.StrSiteid = strSiteId;  
  22. PageEventFooter.StrOrderno = DataSet.Tables[0].Rows[i]["ORDERNO"].ToString(); //theRow["ORDERNO"].ToString();  
  23. writerPdf.PageEvent = PageEventFooter;  
  24. ClsPageNumberCh PageEventHandler = new ClsPageNumberCh();  
  25. writerPdf.PageEvent = PageEventHandler;  
  26. pdfDoc.Open();  
  27. string OrdNo = DataSet.Tables[0].Rows[i]["ORDERNO"].ToString();  
  28. BindPDFDetail(OrdNo);  
  29. BindPDFCarrier(OrdNo);  
  30. BindPDFItem(OrdNo);  
  31. BindPDFRemarksDetail(OrdNo);  
  32. BindPageParagraph();  
  33. pdfDoc.Close();  
  34. byte[] bytes = mStream.ToArray();  
  35. mStream.Close();  
  36. string pdfPath = ConfigurationManager.AppSettings["pdfPath"].ToString() + "Invoice_Orders.pdf";  
  37. File.WriteAllBytes(pdfPath, mStream.ToArray());  
  38. }  

Answers (2)