zoukankan      html  css  js  c++  java
  • NReco.PdfGenerator HtmlToPdfConverter 使用示例(未完成)

                string htmlFilePath = System.IO.Path.GetFullPath(@"data	est.html");
                var pdfConvert = new HtmlToPdfConverter();
                //pdfConvert.Zoom = 0.5f;//缩放比例 0.5倍
                //pdfConvert.Size = PageSize.A3; //纸张大小
                //pdfConvert.Grayscale = true;//灰色
                //pdfConvert.LowQuality = false;
                pdfConvert.LogReceived += (s, e) => {
                    MessageBox.Show(e.Data);
                };
                pdfConvert.GeneratePdfFromFile(htmlFilePath, null, System.IO.Path.GetFullPath(@"data	est.pdf"));
                //string html;
                //using (StreamReader sr = new StreamReader(htmlFilePath))
                //{
                //    html = sr.ReadToEnd();
                //}
                //pdfConvert.GeneratePdf(html, null, System.IO.Path.GetFullPath(@"data	est.pdf"));
    cs
    <html>
    <body>
        <div style="1000px;height:1400px;border:1px solid red;">
            <div style="100px;height:100px;margin-bottom:100px;float:left;border:1px solid blue">
                <img src="E:/test.jpg" style="100%;height:100%;" />
            </div>
        </div>
    </body>
    </html>
    text.html

    常见的问题:

    1、纸张的大小是用的毫米,HTML中用的像素。要知道最大的网页宽度,需要计算。

    DPI(Dots Per Inch,每英寸点数)。图像每英寸长度内的像素点数。

    常见的DPI 是 96 和 72。

    https://www.cnblogs.com/sun-star/p/3934299.html

    2、生成后像素大小改变的问题

    和浏览器导出为PDF显示的大小不一致。

    1、图片不能正常显示的问题。

    E:/test.jpg file:///E:/test.jpg 都不能正常显示,具体格式需要确认

    3、定位问题代码。

    4、编写测试程序

  • 相关阅读:
    二选一的痛定思痛
    .net 代码混淆原理性实践
    什么是 RSS?
    ViewEngine 深入解析与应用实例 {转}
    C#访问修饰符及各种元素的访问修饰符的默认值
    [转]基于VS.NET的自定项目模板研究
    刘若鹏
    System.Configuration 和Connection
    Page.Master.FindControl?还是Page.FindControl?
    模板页中的链接
  • 原文地址:https://www.cnblogs.com/tanl/p/14021810.html
Copyright © 2011-2022 走看看