Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Apr 28, 2015 9:51 pm

I am trying to run the PDF generator as a handler since I need to pass parameters from a web URL (not yet added). I know I need to output this as a binary stream but wanted to know if there was an easy way before I tried writing something. I aso just tried saving the PDF and that did not work. Does this code run as a Handler class? My code is below:

public class HelloWorldHandler : IHttpHandler
{
public HelloWorldHandler()
{
}
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
PdfDocument doc = new PdfDocument();
String url = "URL";
Thread thread = new Thread(() =>
{
doc.LoadFromHTML(url, false, true, true);
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
doc.SaveToFile("/tempfiles/result.pdf");
doc.SaveToHttpResponse("result.pdf", Response, HttpReadType.Save);
doc.Close();

}
public bool IsReusable
{
// To enable pooling, return true here.
// This keeps the handler in memory.
get { return false; }
}
}

Thanks in advance for your help.

Bob

weblications
 
Posts: 1
Joined: Mon Apr 27, 2015 3:16 pm

Wed Apr 29, 2015 9:58 am

Hello,

Thanks for your inquiry.
So sorry that our product doesn't support passing parameters at this stage. We will consider adding it in our future upgrade.

Sincerely,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Return to Spire.PDF