Reputation: 2961
I need to use wkhtmltopdf to get a PDF 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
Upvotes: 1
Views: 1385
Reputation: 574
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.
Upvotes: 3
Reputation: 3777
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();
Upvotes: 3