Using wkhtmltopdf from c# (SharePoint 2010)
I need to use wkhtmltopdf to get a PDF 开发者_Go百科version of an html page. I will not be able to save a file on either side (client or server) for various reasons, so I need to keep everything in streams.
I'm working in SharePoint 2010, and I'd like to convert a page to PDF without having to save a file.
Does anyone have a code snippet, or know how I can do this? Please keep in mind that I am not that proficient with streams, so be a specific as possible.
Thanks,
Ryan
This will just use bytes not streams
// Create and configure PdfConverter
//
var pdfConverter = new PdfConverter();
...
// Get PDF as bytes
//
byte[] bytes = pdfConverter.GetPdfBytesFromUrl(url);
Response.Clear();
Response.ContentType = MediaTypeNames.Application.Pdf;
Response.AddHeader("Content-Disposition", "inline;filename=SharePointPage.pdf");
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
I just started a new project to provide a C# P/Invoke wrapper around wkhtmltopdf.
You can checkout my code at: https://github.com/pruiz/WkHtmlToXSharp
Greets.
精彩评论