How to convert a PDF to Response.OutputStream

I already have PDF files on the network share. I just want to display the PDF in an image control using Image.ImageURL = “image.ashx” so when the page reposts the handler returns an output stream which updates the image.

So far the only thing I’ve found that works is a complex process of converting the PDF (in sPath) to a memorystream using PDFConverter and SavaAsTIFF (you might to check your spelling on Sava).

PdfConverter conv = new PdfConverter();
conv.BindPdf(sPath);
conv.DoConvert();
MemoryStream ms = new MemoryStream();
conv.SavaAsTIFF(ms);

Then I convert the memory stream to a bitmap bmp

Bitmap bmp = new Bitmap(ms);

and finally saving the bitmap -
bmp.Save(Context.Response.OutputStream, ImageFormat.Jpeg);

That works, but there HAS to be a simpler way!

P.S. The original PDF can have multiple pages, each of which I want to display separately, as thumbnails.


This message was posted using Page2Forum from Fill Pdf Form Fields - Aspose.Pdf.Kit Demos
lianaent:

P.S. The original PDF can have multiple pages, each of which I want to display separately, as thumbnails.


Hi Larry,

If you want to display multiple pages as separate images, you can try GetNextImage method. This method converts a single page of a PDF file to your required image format. For further details, you can also have a look at this article.

I hope this helps. If you have any further questions, please do let us know.
Regards,