Click here to Skip to main content
15,885,633 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hi I generated project by c#.net and sql server 2008.I saved doc/pdf file in database.

Now,I want to retrieve doc/pdf file from database and open it by Microsoft Word/Adobe Acrobat software(Microsoft Word/Adobe Acrobat software was installed in my computer).

Please guide me,Thanks.
Posted

Did you even try to Google for an answer? It's pretty obvious. You save the file data as a file, then launch Adobe Acrobat, telling it which file to open. If you need to know how to do any of that, feel free to Google for it. If you are still having problems after having tried to solve them yourself, we're here to help.
 
Share this answer
 
Comments
saeid2010 14-Sep-10 18:27pm    
Hi aspdotnetdev,
i have a method for it:

1- bring binary data from database to dataset
2- convert binary data to byte[] type in dataset
3- write it in target path
4- call specific program for it(c#: process.start(path);)

But,it's long way.
i want to find another way(short way) for solve it.

thanks
AspDotNetDev 14-Sep-10 18:54pm    
Not sure what you mean by "short way". Seems like you have a perfectly good method of displaying the PDF. Is there some reason that's not working for you? What problem are you trying to solve?
saeid2010 15-Sep-10 0:33am    
I want another way that i don't have 3 and 4 step.
I call specific program for it straightly.
ThatsAlok 17-Sep-10 11:10am    
saeid answer would be correct approach. we use this kind of approach in one of our product.
Try This Way :
Code in C#
using System;
using System.Xml;
using System.Web.Configuration;
using System.Web;
using System.Web.SessionState;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI;

public class AdClickHandler : IHttpHandler
{

        public void ProcessRequest(HttpContext context)
        {

                context.Response.ClearHeaders();
                context.Response.ClearContent();
                context.Response.AppendHeader("Pragma", "no-cache");
                context.Response.AppendHeader("Cache-Control", "no-cache");
                context.Response.CacheControl = "no-cache";
                context.Response.Expires = -1;
                context.Response.ExpiresAbsolute = new DateTime(1900, 1, 1);
                context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        context.Response.ContentType = "application/application/vnd.ms-excel"; // Get approprivate Content type mime type
                context.Response.BinaryWrite(MyByteArray);
                context.Response.Flush();

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
  }


try the same application/application/vnd.ms-excel
with Ms-Word
Hope It Helps
:)
 
Share this answer
 
v3
Comments
saeid2010 25-Nov-10 2:13am    
Hi my friend
TNX a lot
bsty123 8-Jul-11 5:06am    
ya its good but how to use this handler in gridview where pdf id is display in column.
Hi it takes long time.
I want to have this way:

1- bring binary data from database to dataset
2- convert binary data to byte[] type in dataset
Now,
3- call specific program for it.

Thanks.
 
Share this answer
 
Comments
Simon Dufour 17-Sep-10 16:08pm    
You can't feed byte data to Acrobat Reader without saving it in a file. Take the data, save it as a .pdf file and launch the app normally.
saeid2010 19-Sep-10 15:44pm    
it's only way for my question?

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