문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top