Esempio n. 1
0
        /// <summary>
        /// 导出HTML文本
        /// </summary>
        private static void ExportHtmlContent(string htmlContent)
        {
            var doc = new HtmlToPdfDocument()
            {
                GlobalSettings =
                {
                    ColorMode   = ColorMode.Color,
                    Orientation = Orientation.Landscape,
                    PaperSize   = PaperKind.A4,
                },
                Objects =
                {
                    new ObjectSettings()
                    {
                        PagesCount     = true,
                        HtmlContent    = htmlContent,
                        WebSettings    = { DefaultEncoding = "utf-8"                   },
                        HeaderSettings ={ FontSize                             =9, Right = "Page [page] of [toPage]", Line = true },
                        FooterSettings ={ FontSize                             =9, Right = "Page [page] of [toPage]" }
                    }
                }
            };

            doc.ExportPDF();
        }
Esempio n. 2
0
        /// <summary>
        /// 导出指定网页
        /// </summary>
        private static void ExportWebPage(string url)
        {
            var doc = new HtmlToPdfDocument()
            {
                GlobalSettings =
                {
                    PaperSize = PaperKind.A4Small
                },

                Objects =
                {
                    new ObjectSettings()
                    {
                        Page = url,
                    }
                }
            };

            doc.ExportPDF();
        }