|
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using Cyotek.GhostScript.PdfConversion;
namespace GhostScriptWebTest
{
public class PdfImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string fileName;
int pageNumber;
Pdf2Image convertor;
Bitmap image;
fileName = context.Server.MapPath("~/" + context.Request.QueryString["fileName"]);
pageNumber = Convert.ToInt32(context.Request.QueryString["page"]);
// convert the image
convertor = new Pdf2Image(fileName);
image = convertor.GetImage(pageNumber);
// set the content type
context.Response.ContentType = "image/png";
// save the image directly to the response stream
image.Save(context.Response.OutputStream, ImageFormat.Png);
}
public bool IsReusable
{ get { return true; } }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.