Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi...

I am working on a project using asp.net and c#.
in my GUI i can select a pdf file by using a fileupload control.
I need this file to be displayed below so that i can read the details.

can any one plz help.This is very urgent....

i've gone thru various helps and found we can use object tag to insert adobe com object and i tried that ..it is working but..


C#
<object data="Pdffilename" type="application/pdf"           style="height:1030px; width: 928px" >
       <param name="SRC" value="='<%=src%>'<br" mode="hold" /> </object>  



the src file how to set at the time of a button click?
Posted
Updated 1-Jul-13 1:12am
v2

Setting SRC using JavaScript will cause security issue.Other way to achieve this first you upload file to the sever in some temp folder than display it and once user confirm it. Move it to the target folder. Below is code for your reference


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div>
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </div>
        <div id="divPDF" runat="server">
    <object data="<%=pdfPath%>" type="application/pdf" style="height:500px; width: "500px" >
    </object>
        </div>
    </div>
    </form>
</body>
</html>


protected string pdfPath;
        protected void Page_Load(object sender, EventArgs e)
        {
            divPDF.Visible = false;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.FileName != "")
            {
                FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName));
                pdfPath = FileUpload1.FileName;
                divPDF.Visible = true;
            }
        }
 
Share this answer
 
Comments
Member 10112611 1-Jul-13 6:01am    
Mahesh Bailwal!!!! Thanks a lot for the solution ....it is working !!!
Member 10112611 1-Jul-13 6:03am    
I need one more help plzzz...

Can i invoke the pdf view function at the time of selecting a file in fileupload control without clicking any other view button?

plz advice...
Member 10112611 1-Jul-13 6:03am    
One more thing ..how can i find the current page of a pdf document using itextsarp to extract that page
Mahesh Bailwal 1-Jul-13 7:05am    
I am not familiar with itextsarp. So please post new question for your new issue so that its visible to everyone and you can have better answer.
I need one more help plzzz...

Can i invoke the pdf view function at the time of selecting a file in fileupload control without clicking any other view button?

plz advice...
 
Share this answer
 

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