Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I m working on a windows application in .net with c#, i want to generate reports in image format,how i generate reports in image format or how to convert PDFs into image format....plz help me..
Posted

To convert PDF file to image in PNG format, Please use lib-pdf
You can download the library here lib-pdf

The code to convert pdf to image is simple,
Please find copied the code :

using (FileStream file = File.OpenRead(@"..\path\to\pdf\file.pdf")) // in file
{
    var bytes = new byte[file.Length];
    file.Read(bytes, 0, bytes.Length);
    using (var pdf = new LibPdf(bytes))
    {
        byte[] pngBytes = pdf.GetImage(0,ImageType.PNG); // image type
        using (var outFile = File.Create(@"..\path\to\pdf\file.png")) // out file
        {
            outFile.Write(pngBytes, 0, pngBytes.Length);
        }
    }
}


In the link i provided, you will reach lib-pdf site home page.

1. Goto downloads tab at the top
2. Download the x86 release binaries (your project must be x86 too)

You will find the dll files there.

Or use this direct link. https://code.google.com/p/lib-pdf/downloads/detail?name=binaries.zip&can=2&q=[^][^]
 
Share this answer
 
v3
In the link i provided, you will reach lib-pdf site home page.

1. Goto downloads tab at the top
2. Download the x86 release binaries (your project must be x86 too)

You will find the dll files there.

Or use this direct link. https://code.google.com/p/lib-pdf/downloads/detail?name=binaries.zip&can=2&q=[^]
 
Share this answer
 
Comments
Sushil Mate 24-Jul-13 5:29am    
please update your first answer instead of posting another solution.
Sarin VT 24-Jul-13 5:40am    
thanks sushi..
will do that :)
AnshumanSharmaji 24-Jul-13 7:27am    
Now It's Working.........Thnx
Sarin VT 24-Jul-13 7:34am    
Then mark it as solution accepted.
Other needn't to open it then..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900