zoukankan      html  css  js  c++  java
  • C#使用Pechkin与CPechkin生成PDF

    http://blog.sina.com.cn/s/blog_5a52cec70102wpcf.html

    1. Pechkin
        从NuGet程序管理器中获得Pechkin,代码示例如下:
                GlobalConfig config = new GlobalConfig();
                SimplePechkin pechkin = new SimplePechkin(config);
                ObjectConfig objectConfig = new ObjectConfig();
                objectConfig.SetPrintBackground(true)
                    .SetLoadImages(true)
                    .SetAffectPageCounts(true)
                    .SetPageUri("http://www.abc.com/");//此处替换为你的uri
                byte[] bytePDF = pechkin.Convert(objectConfig);//此处亦支持html字符串
                File.WriteAllBytes("F:\PDFName.pdf", bytePDF);
    2. CPechkin
        使用Pechkin不能合并多个uri为一个PDF,故引入CPechkin,获得方式与Pechkin同,代码示例如下:
                SynchronizedPechkin sc = new SynchronizedPechkin(
                    new GlobalConfig()
                    .SetMargins(new Margins(100, 100, 100, 100))
                    );
                IList uris = new List
                {
                new Uri(@"http://www.a.com/"),
                new Uri(@"http://www.b.com/")
                };
                byte[] buf = sc.Convert(uris);
                string fn = @"F:PDFName.pdf";
                FileStream fs = new FileStream(fn, FileMode.Create);
                fs.Write(buf, 0, buf.Length);
                fs.Close();

    0

    0

  • 相关阅读:
    android gridview画分割线,如图:
    Devexpress 之gridControl
    Devexpress 之gridControl双击行事件
    Devexpress之popupMenu
    Devexpress之dxErrorProvider
    DevExpress之lookupedit
    Devexpress 汉化 代码 zt
    Devexpress之DateEdit学习,可选择日期时 zt
    Devexpress之barManager
    devpress 很好的中文论坛
  • 原文地址:https://www.cnblogs.com/wdcwy/p/6956102.html
Copyright © 2011-2022 走看看