本文介绍了Pechkin文档/教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我试过wkhtmltopdf它的工作完美......但在服务器上我不能启动一个进程,所以我的解决办法是这样的:的 https://github.com/gmanny/Pechkin 但我不知道如何实现它在我的项目......有什么样?我可以打开并运行 我看看这个例子: 字节[] pdfBuf =新SimplePechkin(新GlobalConfig())转换(< HTML><身体GT;< H1>您好!世界< / H1>< /身体GT;< / HTML> ;); //创建全局配置对象 GlobalConfig GC =新GlobalConfig(); //设置它用流利的符号 gc.SetMargins(新边距(300,100,150,100)) .SetDocumentTitle(测试文件) .SetPaperSize(PaperKind.Letter); // ...等等 //创建器 IPechkin pechkin =新SynchronizedPechkin(GC); //订阅事件 pechkin.Begin + = OnBegin; pechkin.Error + =的OnError; pechkin.Warning + = OnWarning; pechkin.PhaseChanged + = OnPhase; pechkin.ProgressChanged + = OnProgress; pechkin.Finished + = OnFinished; //创建文档配置对象 ObjectConfig OC =新ObjectConfig(); //并用流利的符号太 oc.SetCreateExternalLinks(假) .SetFallbackEncoding(Encoding.ASCII) .SetLoadImages(假)设置它; .SetPageUri(http://google.com); // ...等等 //转换文件字节[] = pdfBuf pechkin.Convert(OC); 但我没有做它的工作......这看起来很容易,但不知道如何实现它... 但我看到GMAN已与它的工作。 感谢您提前...。) 解决方案 下面是我能想到这也将输出到文件最简单的例子。 字节[] = pdfBuf新SimplePechkin(新GlobalConfig())转换(HTML)。 File.WriteAllBytes(路径,pdfBuf); I tried wkhtmltopdf which worked perfectly... But on the server I cant start a process so my solution would be this: https://github.com/gmanny/PechkinBut I have no idea how to implement it in my project... Are there any samples I can just open and run?I had a look at this example:byte[] pdfBuf = new SimplePechkin(new GlobalConfig()).Convert("<html><body><h1>Hello world!</h1></body></html>");// create global configuration objectGlobalConfig gc = new GlobalConfig();// set it up using fluent notationgc.SetMargins(new Margins(300, 100, 150, 100)) .SetDocumentTitle("Test document") .SetPaperSize(PaperKind.Letter);//... etc// create converterIPechkin pechkin = new SynchronizedPechkin(gc);// subscribe to eventspechkin.Begin += OnBegin;pechkin.Error += OnError;pechkin.Warning += OnWarning;pechkin.PhaseChanged += OnPhase;pechkin.ProgressChanged += OnProgress;pechkin.Finished += OnFinished;// create document configuration objectObjectConfig oc = new ObjectConfig();// and set it up using fluent notation toooc.SetCreateExternalLinks(false) .SetFallbackEncoding(Encoding.ASCII) .SetLoadImages(false); .SetPageUri("http://google.com");//... etc// convert documentbyte[] pdfBuf = pechkin.Convert(oc);But I didn't make it work... It looks so easy but no idea how to implement it...But I see Gman has worked with it.Thank you in advance... :) 解决方案 Here is the simplest example I could think of which also writes the output to a file.byte[] pdfBuf = new SimplePechkin(new GlobalConfig()).Convert(html);File.WriteAllBytes(path, pdfBuf); 这篇关于Pechkin文档/教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-22 22:30