Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 14-Sep-10 10:13am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
saeid2010 at 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 at 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 at 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 at 17-Sep-10 11:10am
   
saeid answer would be correct approach. we use this kind of approach in one of our product.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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
Smile | :)
  Permalink  
v3
Comments
saeid2010 at 25-Nov-10 2:13am
   
Hi my friend
TNX a lot
bsty123 at 8-Jul-11 5:06am
   
ya its good but how to use this handler in gridview where pdf id is display in column.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
Simon Dufour at 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 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 354
1 Richard MacCutchan 240
2 OriginalGriff 225
3 Jared Sanow 145
4 Vinay Mistry 133
0 Sergey Alexandrovich Kryukov 5,955
1 OriginalGriff 4,805
2 CPallini 2,473
3 Abhinav S 1,507
4 Richard MacCutchan 1,437


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 18 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100