#星空云诊所#:云诊所-星空如何实现根据界面内容生产PDF文档

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

#星空云诊所#:云诊所-星空如何实现根据界面内容生产PDF文档

在很多项目中,如果客户有特殊需求,需要将某些要打印的内容生产PDF文件,并可以下载,要怎么实现呢?下面就为大家介绍一下如何实现生成PDF文件的方法:

一、生产PDF的过程代码:

     

 private string makepdf(string templateid,string receiveman,string autid,string idnum)

        {

            PrintExportInfo pExInfo = new PrintExportInfo();

            string src = DateTime.Now.ToString();

            string filename =  receiveman + "-" + idnum + "-" + autid + ".PDF";

            string filePath = Path.Combine(temppath, filename);

            pExInfo.FilePath = filePath;//文件输出路径

            pExInfo.PageId = this.View.PageId;

            pExInfo.FormId = this.View.BillBusinessInfo.GetForm().Id;

            pExInfo.BillIds = new List<string> { this.View.Model.GetPKValue().ToString() };

            pExInfo.TemplateIds = new List<string> { templateid };

            pExInfo.FileType = ExportFileType.PDF;//文件格式

            pExInfo.ExportType = ExportType.ByPage;//导出格式


            if (this.View is IBillViewService)

            {

                IBillViewService viewService = this.View as IBillViewService;

                viewService.ExportNotePrint(pExInfo);

            }

            return filename;

        }

    注意模板ID,也就是我们套打的模板,这些生产的内容都与套打有关系的,获取模板的方法如下:

    

 /// <returns></returns>

        public string GetSingleNoteID()

        {

            var templateID = string.Empty;


            if (this.SettingInfo != null)

            {

                foreach (Dictionary<string, object> obj in this.SettingInfo)

                {

                    if (!obj["key"].IsNullOrEmptyOrWhiteSpace()

                        && obj["key"].Equals("reportNote")

                        && !obj["value"].IsNullOrEmptyOrWhiteSpace()

                        && !obj["value"].Equals("empty"))

                    {

                        //套打配置的模版

                        templateID = obj["value"].ToString();

                        break;

                    }


                    if (obj["key"].IsNullOrEmptyOrWhiteSpace()

                       && !obj["value"].IsNullOrEmptyOrWhiteSpace()

                       && !obj["value"].Equals("empty"))

                    {

                        //套打配置的模版

                        templateID = obj["value"].ToString();

                    }

                }

            }

            //templateID = CheckTemplateID(templateID);

            if (templateID.IsNullOrEmptyOrWhiteSpace())

            {

                //获取设计时配置的套打模板

                templateID = this.View.BusinessInfo.GetForm().Note;

            }


            return templateID;

        }

二、文件下载实现:

   

 protected void DownLoadPDFFile(string url)

        {

            DynamicFormShowParameter param = new DynamicFormShowParameter();

            param.FormId = "BOS_FileDownLoad";

            param.OpenStyle.ShowType = ShowType.Modal;

            param.CustomParams.Add("IsExportData", "true");

            param.CustomParams.Add("url", url);

            this.View.ShowForm(param);


        }



       

    


#星空云诊所#:云诊所-星空如何实现根据界面内容生产PDF文档

在很多项目中,如果客户有特殊需求,需要将某些要打印的内容生产PDF文件,并可以下载,要怎么实现呢?下面就为大家介绍一下如何实现生成PDF...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息