1. 程式人生 > >FastReport後臺生成pdf不彈出窗體

FastReport後臺生成pdf不彈出窗體

            Report rep = new Report();
            rep.Load(@"C:\Users\Jeffrey\Desktop\PendingDetection.frx");
            ///關閉生成進度條
            EnvironmentSettings eSet = new EnvironmentSettings();
            eSet.ReportSettings.ShowProgress = false;
            ///關閉對話方塊
            rep.PrintSettings.ShowDialog = false;
            rep.Prepare();
            FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
            rep.Export(export, "PendingDetection.pdf");


            //初始化一個PdfDocument類例項,並載入PDF文件
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"C:\Users\Jeffrey\Desktop\ConsoleApp1\ConsoleApp1\bin\Debug\PendingDetection.pdf");
            //遍歷PDF每一頁
            for (int i = 0; i < doc.Pages.Count; i++)
            {
                //將PDF頁轉換成Bitmap圖形
                System.Drawing.Image bmp = doc.SaveAsImage(i);
                //將Bitmap圖形儲存為Png格式的圖片
                string fileName = string.Format("Page-{0}.png", i + 1);
                bmp.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
            }