当前位置: 首页>>代码示例>>C#>>正文


C# Engine.Render方法代码示例

本文整理汇总了C#中Engine.Render方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.Render方法的具体用法?C# Engine.Render怎么用?C# Engine.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Engine的用法示例。


在下文中一共展示了Engine.Render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        public TemplateResponse Render(RenderingOptions options)
        {
            if (options == null)
            {
                throw new FaultException<string>("Rendering options are null");
            }

            var _param = new RenderingParameters();

            if (options.OutputFormat == OutputFormat.PDF)
            {
                _param.OutputFormat = Engine.OutputFormat.PDF;
                _param.PDFOutputFlags = Engine.PDFFlags.PDF14;
            }
            else if (options.OutputFormat == OutputFormat.HTML)
            {
                _param.OutputFormat = Engine.OutputFormat.HTML;
                _param.HtmlOutputSettings = new Engine.HtmlOutputSettings
                {
                     GenerateHtmlDocument = false
                };
            }
            else
            {
                // no other format is supported...
                throw new FaultException<string>("Rendering.OutputFormat not supported");
            }

            var template = XDocument.Parse(options.Template);

            Stream stream = new MemoryStream();
            template.Save(stream);
            // Rewind the stream ready to read from it elsewhere
            stream.Position = 0;

            _param.Template = new LocalDocumentTemplate(stream, null, Engine.XsltEngine.MSXML, "en_EN", null);
            var _output = new OutputInformation();
            var ds = DataSource(options);

            using (var outputStream = new MemoryStream())
            {
                Engine engine = new Engine();
                engine.Render(ds, outputStream, _param, ref _output);
                return new TemplateResponse
                {
                    Response = outputStream.ToArray()
                };
            }
        }
开发者ID:hahmed,项目名称:tr,代码行数:49,代码来源:Templater.svc.cs

示例2: GeneratePdf

        /// <summary>
        /// This method will generate Pdf file from HtmlDataSource property and will use
        /// RenderingParameters as pdf file rendering parameters
        /// </summary>
        /// <param name="applicationId">Form applicatio id</param>
        /// <param name="html">Html content to crete pdf</param>
        public void GeneratePdf(int applicationId, string html)
        {
            this.HtmlDataSource = html;
            this.PdfFileLocationPath = HostingEnvironment.MapPath(@"~/Content/pdfs");

            if (string.IsNullOrEmpty(this.PdfFileLocationPath))
            {
                throw new ArgumentException("Specify pdf file saving location");
            }

            string outFilePath = Path.Combine(this.PdfFileLocationPath, applicationId.ToString());

            #if DEBUG
            // For testing purpose save html
            File.WriteAllText(outFilePath + ".html", html);
            #endif

            using (FileStream outputStream = new FileStream(outFilePath + ".pdf", FileMode.Create))
            {
                OutputInformation outInfo = new OutputInformation();
                var processInfo = new PdfCreateProcessInfo();
                processInfo.OnMassageArrived += this.ProcessInfo_OnMassageArrived;

                outInfo.NotificationEvents = processInfo;
                var pdfEngine = new Engine();

                pdfEngine.Render(this, outputStream, this.RenderingParameters, ref outInfo);

                if (!this.IsError)
                {
                    Attachment att = new Attachment
                    {
                        ApplicationFormId = applicationId,
                        AttachmentType = DbObjects.OLE.TableRefEnums.AttachmentType.PdfApplication,
                        Description = "pdf document",
                        FileName = applicationId.ToString(),
                        ServerFileName = "~/Content/pdfs/" + applicationId.ToString() + ".pdf"

                    };
                    this.databaseHelper.Create<Attachment>(att);
                    this.databaseHelper.FlushChanges();
                }
            }
        }
开发者ID:targitaj,项目名称:m3utonetpaleyerxml,代码行数:50,代码来源:PdfGenerator.cs


注:本文中的Engine.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。