我尝试了完美运行的 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);
但我没有让它工作......它看起来很容易,但不知道如何实现它......但我看到 Gman 已经使用它了。
先感谢您... :)