How do I convert a PDF to a png

I am writing a MS SharePoint web part to display a list. The list contains an attachment column.

SharePoint will display jpg, png, etc without problem but will not display a pdf.

I would like to convert the pdf to a png before inserting the file into the SP Grid Viewer.

I downloaded the PDF for .Net trial (6.0) and PDF Kit for .Net trial (5.7).

I tried using the Kit to convert, but recieved 'Could not load file or Assembly errors'.

What is the best way to convert pdf's to png or jpg? The pdf exists as a SharePoint list item

and I want to display the png on a web page - not save it to a hard disk.

Thanks

-Paul

Hello Paul,

Thanks for your interest in our products.

Recently we have released a new version of Aspose.Pdf for .NET 6.0.0 which includes the combined features of Aspose.Pdf and Aspose.Pdf.Kit. So now you can use the single component to create a PDF document from scratch or you can use it to manipulate existing PDF documents.

As per your requirements, you can load the PDF document from sharepoint list and pass it to Aspose.Pdf so that it can be converted into Image format. Finally you can save the resultant Image into Stream object and display it inside a webpage. I would suggest you to please visit the following link for required information on Convert All PDF Pages to PNG Images.

You may also consider Aspose.Pdf.Facades namespace to accomplish the same requirement. Please visit the following link for information on Convert PDF Pages to Different Image Formats (Facades)

In order to save the final image to Stream object, please try using public void GetNextImage(Stream,ImageFormat); method of PdfConverter Class.

In case I have not properly understood your requirement or you have any further query, please feel free to contact. We apologize for your inconvenience.

Thanks,

I uninstalled both Aspose Pdf for .Net and Aspose Pdf Kit for .Net. Then I reinstalled

Aspose PDF for .Net only.

I copied the code from the first example and have a couple of questions:

1) These 2 lines of code will not compile --

Resolution resolution = new Resolution (300);

PngDevice pngDevice = new PngDevice (resolution);

I have included a reference to Aspose.pdf and added a using statement to

Aspose.pdf and Aspose.pdf.fascades. Where are Resolution and PngDevice defined?

2) How can I access the image? Is it a file on the hard drive of the server or can I assign the

stream to the ImageField I am using on the Web page?

Something like

Row["Picture"] = imageStream;

where Row is a row in the GridView and Picture is the image column.

Thanks

- Paul

Hello Paul,

1) In order to access Resolution and PngDevice classes, please try using Aspose.Pdf.Devices; namespace.

2) Once the PDF file has been converted into Image format, please save the resultant image into Stream object. Please take a look over following code lines.

[C#]

// create a MemoryStream object
MemoryStream StreamObject = new MemoryStream();
//convert a particular page and save the image to stream
pngDevice.Process(pdfDocument.Pages[1], StreamObject);

Please note that we recently have observed that PDF to Image conversion is causing issues when tested over Windows 7. We have been able to notice this issue over Windows7 Professional 64Bit in a Visual Studio 2010 and VisualStudio 2008 projects. For the sake of correction, we have logged this problem as PDFNEWNET-29399 in our issue tracking system. Our development team is looking into the details of this problem and will keep you posted on the status of correction. We apologize for your inconvenience.

Please note that PDF pages are properly being converted into image format when tested over Windows XP in VisualStudio 2005.

Thanks, that allowed the program to compile --

however, when I run the program I get a

'Could not load file or assembly Aspose.pdf,version 6.0.0.0,

culture=neutral,public token key = 47b2d0fcacdd3eb6 or one of its

dependencies. The system cannot find the file specified.

I get this error is I run the program using the debugger in VS2010 or if I deploy

the solution to the server and try to load the page using a web browser.

Thanks

-Paul