Save Each PreparedPage to Individual Pdf with Specific Name From Each Page

  my customised code was written with great help from dear friend ipong;

https://forum.fast-report.com/en/profile/ipong

 FastReport.Preview.PreparedPages prpPages = Report.PreparedPages;

   int pageCount = prpPages.Count;


   for (int i = 0; i < pageCount; i++)

   {

    ReportPage objPage = prpPages.GetPage(i);   

    TableCell StudentCode_cell=(TableCell)objPage.FindObject("Cell64");

    TableCell StudentName_cell=(TableCell)objPage.FindObject("Cell55");

     

    using (FastReport.Report reportExport = new FastReport.Report())

    {

     using (MemoryStream stream = new MemoryStream())

     {

      prpPages.Save(stream);

      stream.Position = 0;


      reportExport.LoadPrepared(stream);


      for (int j = pageCount - 1; j >= 0; j--)

      {

       if (j != i)

        reportExport.PreparedPages.RemovePage(j);

      }


      using (FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport())

      {

       pdf.ShowProgress = true;

       pdf.OpenAfterExport=true;

       pdf.EmbeddingFonts = true;

       pdf.Compressed = true;

       pdf.AllowPrint = true;

       pdf.Export(reportExport,"d:\\"+ StudentCode_cell.Text+StudentName_cell.Text+".pdf");

      }


     }


    }


   }

Leave a Comment