Convert to PDF into Images....

Posted by Mohansubramanian under ASP.NET on 5/16/2015 | Points: 10 | Views : 419 | Status : [Member] | Replies : 3
Hi,

how i can convert my pdf file into image from file upload control. if pdf file will have 5 pages, it should convert into has five images only.pls help asap. i want this using c# with asp.net

Regards,
Mohan Subramanian
http://mohanks.com



Responses

Posted by: Anatol on: 6/11/2015 [Member] Starter | Points: 25

Up
0
Down
To my knowledge, PDF format itself is not a web-friendly format. So you need to use a programming SDK (like leadtools) that has a document conversion service that you can deploy at the server side.
You can pass the PDF file's data from the client to the service, convert the PDF file to different images (save each page in a separate image file) and then pass-back the result images from the service (at the server side) to the client.
I found the following tutorial video that might help:
https://www.youtube.com/watch?v=UCKFffkXD1Y

Mohansubramanian, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oliver32 on: 6/12/2015 [Member] Starter | Points: 25

Up
0
Down
Imports .NET PDF API https://pdfapi.codeplex.com , then you're able to convert PDF to image with following code. Remember to use a for loop to convert each PDF page into an individual image.

PdfDocument doc = new PdfDocument();
doc.LoadFromFile("sample.pdf");
Bitmap bmp =doc.SaveAsImage(0);
Image emf = doc.SaveAsImage(0,Spire.Pdf.Graphics.PdfImageType.Metafile);
Image zoomImg = new Bitmap((int)(emf.Size.Width * 2), (int)(emf.Size.Height * 2));
using (Graphics g = Graphics.FromImage(zoomImg))
{
g.ScaleTransform(2.0f, 2.0f);
g.DrawImage(emf, new Rectangle(new Point(0, 0), emf.Size), new Rectangle(new Point(0, 0), emf.Size), GraphicsUnit.Pixel);
}
bmp.Save("convertToBmp.bmp", ImageFormat.Bmp);
System.Diagnostics.Process.Start("convertToBmp.bmp");


Mohansubramanian, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Arronlee on: 8/6/2015 [Member] Starter | Points: 25

Up
0
Down
Hi, Oliver.
I wonder how can I deal with these codes. Do I need another PDF to image converter (like: http://www.pqscan.com/pdf-to-image/ ) to help me with that?

Mohansubramanian, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response