You cannot do this with iText, since it cannot display or rasterize vector graphics in PDF files.
Option 1:
If the GPL license works for you, you can rasterize your PDF file using Imagemagick + GNU Ghostscript, but AFAIK you will have to write the output to the file in this case.
Command line example:
convert -density 300 -depth 8 c:\temp\mydoc.pdf c:\temp\myrasterimage.png
Codeplex also has a .net shell that might work for you: ImageMagick.NET
Option A:
If you have a commercial library for you, you can try Amyuni PDF Creator.Net . You can use the IacDocument.ExportToJpg method, which requires writing to a file, or you can use the IacDocument.DrawCurrentPage method, which can be useful for writing output to a memory stream.
Sample code to export a single page using IacDocument.DrawCurrentPage to a memory stream:
const int twipsPerInch = 1440; const int MM_ISOTROPIC = 7; private static MemoryStream RasterizePDF(string filePath, int pageIndex, int targetDPI) { Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument(); doc.SetLicenseKey("Evaluation", "07EFC00...77C23E29"); FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); doc.Open(fs, "");
Disclaimer: I am currently working as a library developer
source share