首页 > Web开发 > 详细

NReco.PdfGenerator HtmlToPdfConverter 使用示例(未完成)

时间:2020-11-23 00:26:30      阅读:70      评论:0      收藏:0      [点我收藏+]
技术分享图片
            string htmlFilePath = System.IO.Path.GetFullPath(@"data\test.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\test.pdf"));
            //string html;
            //using (StreamReader sr = new StreamReader(htmlFilePath))
            //{
            //    html = sr.ReadToEnd();
            //}
            //pdfConvert.GeneratePdf(html, null, System.IO.Path.GetFullPath(@"data\test.pdf"));
cs
技术分享图片
<html>
<body>
    <div style="width:1000px;height:1400px;border:1px solid red;">
        <div style="width:100px;height:100px;margin-bottom:100px;float:left;border:1px solid blue">
            <img src="E:/test.jpg" style="width:100%;height:100%;" />
        </div>
    </div>
</body>
</html>
text.html

存在的问题:

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

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

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

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

3、定位问题代码。

4、编写测试程序

NReco.PdfGenerator HtmlToPdfConverter 使用示例(未完成)

原文:https://www.cnblogs.com/tanl/p/14021810.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!