Hello Dear All
i am Generating thumbnail images from PDF file in asp.net with c#.net. this is working fine in VS 2008 windows application.. But is not working with web application..here is my code...please help me
using
System;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
System.Drawing;
using
System.Windows.Forms;
using
System.Runtime.InteropServices;
using
Acrobat;
using
System.Reflection;
using
System.Runtime.CompilerServices;
using
System.Deployment;
public
partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private void generateThumbnailForPDF(string fileName)
{
CAcroPDDoc doc = null;
CAcroPDPage page = null;
try
{
// instanciate adobe acrobat
doc = (
CAcroPDDoc)new Acrobat.AcroPDDocClass();
if (doc.Open(fileName))
{
if (doc.GetNumPages() > 0)
{
// get reference to page
// pages use a zero based index so 0 = page1
page = (
CAcroPDPage)doc.AcquirePage(0);
AcroPoint pt = (AcroPoint)page.GetSize();
AcroRect rect = new AcroRectClass();
rect.Top = 0;
rect.Left = 0;
rect.right = pt.x;
rect.bottom = pt.y;
page.CopyToClipboard(rect, 50, 50, 100);
object obj = page;
IDataObject data = Clipboard.GetDataObject();
System.Drawing.
Bitmap bmp = (System.Drawing.Bitmap)data.GetData(DataFormats.Bitmap);
// calculate new height and width for thumbnail and maintain aspect ratio
int h = (int)((double)pt.y * ((double)100 / (double)pt.x));
int w = 100;
// create thumbnail
System.Drawing.
Image img = bmp.GetThumbnailImage(50, 50, null, IntPtr.Zero);
Session[
"ThumbNailImaage"] = img;
}
}
}
catch
{
//if (doc == null)
MessageBox.Show"Acrobat is not installed. Adobe Acrobat is required.", "Acrobat no Installed", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
if (page != null) Marshal.ReleaseComObject(page);
if (doc != null) Marshal.ReleaseComObject(doc);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string fileName = FileUpload1.PostedFile.FileName;
generateThumbnailForPDF(fileName);
}
}
Please Help me
Thanks in Advanced