This project is read-only.

How to Display PDF/DOC in asp.net and C# using api.

Jun 4, 2010 at 7:04 AM

hi,

i want to display pdf/doc file in my web page in asp.net and using c# code. but i don't know how to... and i want to also give facility to download option in this.

 

please help me out,

 

thanks,

 

--

Ankit

Coordinator
Jun 4, 2010 at 3:39 PM
Please refer to the source code. There is an example web site therein.

- Paul




On Jun 4, 2010, at 2:04 AM, "akgandhi85" <notifications@codeplex.com> wrote:

From: akgandhi85

hi,

i want to display pdf/doc file in my web page in asp.net and using c# code. but i don't know how to... and i want to also give facility to download option in this.

please help me out,

thanks,

--

Ankit

Jun 5, 2010 at 4:37 AM

hi paul,

 thanks for your reply,

  here, i give you how i write code. and also try it with javascript api but that way i m not success by this way i can display pdf file but i m not able to enable download option and if any other way to display pdf then please give me code.. thanks in advance

 

1) its my aspx page.

 

<body>
    <form id="form1" runat="server">
    <div>
        <iframe id="frmDoc" width="400" height="500" runat="server" ></iframe>

      
    <asp:LinkButton ID="btnDownload" runat="server" OnClick="btnDownload_Click">Download</asp:LinkButton>
    </form>
</body>

 

3) its my .cs page.

 

protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            Scribd.Net.Service.APIKey = "APIKEY";

            Scribd.Net.Service.SecretKey = "sec-KEY";
            Scribd.Net.Service.PublisherID = "pub-KEY";

            bool login = Scribd.Net.User.Login("Username", "password");


            Scribd.Net.Document.Uploaded += new EventHandler<Scribd.Net.DocumentEventArgs>(Document_Uploaded);
            Scribd.Net.Document doc = Scribd.Net.Document.Upload(MapPath("test.pdf"), Scribd.Net.AccessTypes.Private, false);
            
            string fullUrl = @"http://www.scribd.com/full/{0}?access_key={1}";
            frmDoc.Attributes.Add("src", string.Format(fullUrl, doc.DocumentId, doc.AccessKey));            
            Session["DocID"] = doc.DocumentId;
        }


        //Scribd.Net.Document doc = Scribd.Net.Document.Upload(MapPath("test.pdf"), true, false);
        //doc.DocumentType = "doc";

        //doc.Title = "Test Application from ankit";
        //doc.Author = "Ankit Gandhi";
        //doc.Category = "Asp.Net";
        //doc.Description = "Api Testing";
        //doc.Save();


    }

    void Document_Uploaded(object sender, Scribd.Net.DocumentEventArgs e)
    {
        
    }
    protected void btnDownload_Click(object sender, EventArgs e)
    {
        int docid = Convert.ToInt32(Session["DocID"]);
        Scribd.Net.Document.Download(docid);       
    }

 

 

 

regards,

Ankit

Aug 20, 2010 at 11:57 AM

Hi Paul,

I am able to upload the document through my ASP.Net, C# application but I am unable to view the uploaded document through the doc_id can you please provide me a sample code to show the document in asp.net with the download option.

 

I have seen all the sample codes but not able to find a suitable one. Please provide me a code.

 

Thanks