欢迎莅临 SUN WU GANG 的园子!!!

世上无难事,只畏有心人。有心之人,即立志之坚午也,志坚则不畏事之不成。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 public void SaveToPDF<TModel>(List<TModel> model, string content, string saveFilePath)
        {
            if (model == null) return;

            Report report = new Report();
            report.LoadFromString(content);

            FillReport(report, model, "print");
            //运行报表
            report.Prepare();
            PDFExport export = new PDFExport();
            report.Export(export, saveFilePath);
            report.Dispose();
        }

 /// <summary>
        /// 文件转换二进制数据(用于保存数据库)
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <returns>二进制</returns>
        public byte[] FileConvertByte(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return null;
            }
            byte[] bytContent = null;
            System.IO.FileStream fs = null;
            System.IO.BinaryReader br = null;
            try
            {
                fs = new FileStream(filePath, System.IO.FileMode.Open);
                br = new BinaryReader((Stream)fs);
                bytContent = br.ReadBytes((Int32)fs.Length);
                fs.Close();
                br.Close();
            }
            catch
            {
                fs.Close();
                br.Close();
                return null;
            }
            return bytContent;
        }

  

posted on 2018-09-07 10:27  sunwugang  阅读(456)  评论(0编辑  收藏  举报