Pechkin文档/教程

use*_*729 0 html c# pdf pechkin

我尝试了wkhtmltopdf完美的工作...但在服务器上我无法启动一个过程所以我的解决方案将是这样的:https://github.com/gmanny/Pechkin

但是我不知道如何在我的项目中实现它......我可以打开并运行任何样品吗?

我看了一下这个例子:

byte[] pdfBuf = new SimplePechkin(new GlobalConfig()).Convert("<html><body><h1>Hello world!</h1></body></html>");

// create global configuration object
GlobalConfig gc = new GlobalConfig();

// set it up using fluent notation
gc.SetMargins(new Margins(300, 100, 150, 100))
  .SetDocumentTitle("Test document")
  .SetPaperSize(PaperKind.Letter);
//... etc

// create converter
IPechkin pechkin = new SynchronizedPechkin(gc);

// subscribe to events
pechkin.Begin += OnBegin;
pechkin.Error += OnError;
pechkin.Warning += OnWarning;
pechkin.PhaseChanged += OnPhase;
pechkin.ProgressChanged += OnProgress;
pechkin.Finished += OnFinished;

// create document configuration object
ObjectConfig oc = new ObjectConfig();

// and set it up using fluent notation too
oc.SetCreateExternalLinks(false)
  .SetFallbackEncoding(Encoding.ASCII)
  .SetLoadImages(false);
  .SetPageUri("http://google.com");
//... etc

// convert document
byte[] pdfBuf = pechkin.Convert(oc);
Run Code Online (Sandbox Code Playgroud)

但是我没有让它工作......看起来很容易,但不知道如何实现它......但我看到Gman已经使用它了.

先感谢您... :)

bli*_*ins 7

这是我能想到的最简单的例子,它也将输出写入文件.

byte[] pdfBuf = new SimplePechkin(new GlobalConfig()).Convert(html);
File.WriteAllBytes(path, pdfBuf);
Run Code Online (Sandbox Code Playgroud)