Wednesday, October 1, 2008

C# convert PDF to image format

The solution generally is provided by 3rd party component. In many cases it is not free. E.g., PDFRasterizer.NET component, PDF4NET etc.

Here's one solution: http://www.mobileread.com/forums/showthread.php?t=10137

The GFL SDK/GFLAx (http://www.xnview.com/en/gfl.html) free library component can be used to convert PDF to image format. It works for ASP, VB, C# etc. GhostScript (http://sourceforge.net/projects/ghostscript/) is required for it to work.

Example code in C#:

{
string file = "D:/test.pdf";
string image = "D:\\test.png";

try
{
GflAx.GflAxClass g = new GflAx.GflAxClass();
g.EpsDpi = 150;
g.Page = 1;
g.LoadBitmap(file);
g.SaveFormat = GflAx.AX_SaveFormats.AX_PNG;
g.SaveBitmap(image);
MessageBox.Show(this, "PDF to PNG conversion ended");
}
catch (Exception ex) {
MessageBox.Show(this, "GflAx error: " + ex.Message);
}
}

barcode reader and writer

libdmtx - library of data matrix. Currently hosted at http://www.libdmtx.org/

Blog Archive

Followers