Click here to Skip to main content
15,918,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm using asp.net ,C# to display a pdf file in a page.
see code below
in aspx file

C#
<object data="<%=pdfPath%>" type="application/pdf"    
                    style="height:812px; width: 603px"500px" align="top" >
                </object>


in aspx.cs file (src is the file upload control to select pdf file

C#
protected void ShowPdf()
     {
       
     
        if (src.FileName != "")
        {
            lblFile.Text = Server.MapPath(src.FileName)
            src.SaveAs(Server.MapPath(src.FileName));
            pdfPath = src.FileName;
          
            divPDF.Visible = true;
        } 
    }


this is working fyn..

now what i need is to extract the page where cursor is focusing to another folder.
i tried the below code

C#
PdfExtractorUtility Epdf = new PdfExtractorUtility();
protected void cmdExtract_Click(object sender, EventArgs e)
      {
                    
          PdfReader r = new PdfReader(lblFile.Text);
         
          int n = r.NumberOfPages;
          String[] labelstrings = new String[n];
          labelstrings = PdfPageLabels.GetPageLabels(r);
          Response.Write(labelstrings);
          Epdf.ExtractPage(lblFile.Text, Server.MapPath(dest.FileName),labelstrings[0]);
}

where extract page is the function i got from itextsharp
see
http://www.codeproject.com/Articles/559380/SplittingplusandplusMergingplusPdfplusFilesplusinp#iTextExampleCodeExtractSinglePage

but the pagenumber is not coming into the labelstring variable.
Please advice how to get the current page number of pdf
Posted
Updated 3-Jul-13 1:52am
v3
Comments
Member 10112611 15-Aug-13 8:05am    
I posted this problem 1 month back...still couldn't find a solution..can anybody plzzz help?

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