locked
Open and Save PDF RRS feed

  • Question

  • User158811806 posted

    The following code opens up a fillable pdf and takes over the current page overwriting the page, the code that is commented out opens up pdf in the same window but it is so tiny and dificult to read.

    1.  How do I code so the pdf is opens up in a new page and gives an option to save the file. And, then, return back to the page?

    2. I also want to see an option to open pdf in the same page by hiding all page buttons/fields/labels etc. and gives an option to save pdf. Once saved, re-display all options that were on the page.

            <div class="container-fluid">
                <div class="first">
                     <div class="row">
                    <div class="col-lg-4">
                        <div id="div1" class="st-box" runat="server">
                             <button id="Button1" class="button" runat="server" style="vertical-align:middle; width:100%" 
                                    onserverclick="View"><span id="spanButton1" runat="server" >Button 1 </span></button>
                            <p>
                                This is a test
                            </p>
                       </div>
             </div>
    
    
    <--	<div class="container-fluid">
                <div class="first">
                    <div class="row">
                        <div class="col-lg-4">
                            <div id="nd-box" class="nd-box">
                                <div class="title">
                                    <asp:Literal ID="Literal1" runat="server" />
                                </div>
                                <div class="content">
                                    <p>
                                        We can create as many div as many we want side by 
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div> -->
    
    protected void bttnpdf_Click(object sender, EventArgs e)
        {
            string FilePath = Server.MapPath("//MyPDF.pdf");
            WebClient User = new WebClient();
            Byte[] FileBuffer = User.DownloadData(FilePath);
            if (FileBuffer != null)
            {
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-length", FileBuffer.Length.ToString());
                Response.BinaryWrite(FileBuffer);
            }
        }

    Sunday, July 5, 2020 6:40 AM

All replies