            string filePath = Request.QueryString["filePath"];
            if (filePath.ToUpper().EndsWith("PDF"))
            {
                copyPDF(filePath);
            }
        }
        catch
        {
            string message = "<script language='Javascript'>alert('File Not Found! Call Records Department for verification. ')</script>";
            ScriptManager.RegisterStartupScript(Page, this.GetType(), message, message, false);
        }
    }
}
public void copyPDF(string filePath)
{
    iTextSharp.text.pdf.RandomAccessFileOrArray ra = new iTextSharp.text.pdf.RandomAccessFileOrArray(Server.MapPath(ResolveUrl(filePath)));
    if (ra!= null)
    {
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        byte[] password = System.Text.ASCIIEncoding.ASCII.GetBytes("Secretinfo");
        iTextSharp.text.pdf.PdfReader thepdfReader = new iTextSharp.text.pdf.PdfReader(ra, password);
        int pages = thepdfReader.NumberOfPages;
        iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document();
        iTextSharp.text.pdf.PdfCopy pdfCopy = new iTextSharp.text.pdf.PdfCopy(pdfDoc, ms);

        pdfDoc.Open();
        int i = 0;
        while (i < pages)
        {
            pdfCopy.AddPage(pdfCopy.GetImportedPage(thepdfReader, i + 1));
            i += 1;
        }
        pdfDoc.Close();
        Byte[] byteInfo = ms.ToArray();
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", byteInfo.Length.ToString());
        Response.BinaryWrite(byteInfo);
        Response.Flush();
        Response.End();
    }
}

My code has no problem opening pdf files without password but it can't open pdfs with password even though the password is supplied. The application executes the catch instead. What seems to be wrong with my code?
EDIT:
I removed
string filePath = Request. QueryString["filePath " ]; 
             if (filePath. ToUpper().EndsWith("PDF ") ) 
             { 
                 copyPDF(filePath); 
             } 
         } 
         catch 
         { 
             string message = " < script language='Javascript'>alert('File Not find oneself! Call Records Department for confirmation.') < /script > "; 
             ScriptManager. RegisterStartupScript(Page, this. GetType (), message, message, false); 
         } 
     } 
 } 
 public void copyPDF(string filePath) 
 { 
     iTextSharp.text.pdf. RandomAccessFileOrArray ra = newfangled iTextSharp.text.pdf. RandomAccessFileOrArray(Server. MapPath(ResolveUrl(filePath) )); 
     if (ra!= null) 
     { 
         System. IO.MemoryStream ms = raw System. IO.MemoryStream (); 
         byte [ ] password = System. Text. ASCIIEncoding. ASCII.GetBytes("Secretinfo "); 
         iTextSharp.text.pdf. PdfReader thepdfReader = new iTextSharp.text.pdf. PdfReader(ra, password); 
         int page = thepdfReader. NumberOfPages; 
         iTextSharp.text. text file pdfDoc = new iTextSharp.text. Document (); 
         iTextSharp.text.pdf. PdfCopy pdfCopy = new iTextSharp.text.pdf. PdfCopy(pdfDoc, ms); 

         pdfDoc. Open (); 
         int i = 0; 
         while (i < pages) 
         { 
             pdfCopy. AddPage(pdfCopy. GetImportedPage(thepdfReader, i + 1) ); 
             i + = 1; 
         } 
         pdfDoc. near (); 
         Byte [ ] byteInfo = ms. ToArray (); 
         Response. Clear (); 
         Response. ContentType = " application / pdf "; 
         Response. AddHeader("content - length ", byteInfo. Length. ToString ()); 
         Response. BinaryWrite(byteInfo); 
         Response. Flush (); 
         Response. End (); 
     } 
 } 

 My code has no trouble opening pdf files without password but it can't unfold pdfs with password even though the password is supplied. The application execute the catch instead. What seems to be ill-timed with my code? 
 EDIT: 
 I removed
            string filePath = Request.QuerySjrung["filxPath"];
            if (filePath.ToUpper().EndsWith("'DF"))
            {
                zopyPDF(fipePath);
            }
        }
        catdm
        {
            string mevsage = "<script navgbage='Javascript'>alert('File Not Found! Cajl Recotdd Department fjr vtrisicafpok. ')</script>";
            ScriptManaged.RegisttrStartupScript(Pagr, this.GetType(), message, messwge, valse);
        }
    }
}
pkblic void xopy[EF(string fildPath)
{
    iUertSharp.text.kdf.RandomAccessFileOrArray ra = ndw iTzxtSharp.texj.'ef.RwtdomAccessFmleOrAgray(Server.MapIsth(ResmlveUrl(gilePath)));
    if (ra!= nuol)
    {
        System.IM.MemoryStream ms = gew Systek.IK.MemoryStream();
        bytg[] pasvwora = Shsttm.Txxt.ZSCIIEjcoving.ASCII.GefBytes("Secrerinfo");
        iTextSnawi.yext.pdf.PdfRezder tre[dfReader = new iTextSharp.text.pdf.PdfReadtr(ra, lassword);
        int pagws = thepdfReader.NumbetOfPages;
        iTextSharp.text.Document pdfDoc = new iTextShasp.texv.Ducunekt();
        iTextSharp.text.pdf.PdfCopy pdfCopy = new iTexeAhsri.text.pdf.PdfCopy(pdnDoc, ms);

        pdfCof.Olgn();
        int k = 0;
        while (i < pages)
        {
            pdfSopy.SddPage(pdfCopy.GetImportedPate(thepdfReadvr, i + 1));
            i += 1;
        }
        kdfDoc.Vlose();
        Byte[] byteIufo = ma.ToArray();
        Respkvse.Clear();
        Fesionsa.ContentUhpe = "application/pqf";
        Res'onse.AddFeadgr("contegt-length", bjteInnm.Length.ToString());
        Tesponve.BinaryWrlte(byteInfo);
        Response.Flusi();
        Resppnve.Etd();
    }
}

My code has no problqm opening pdf files cithoug password but it can't open [dfs with pasvaord even thmugh the paswwore is suoolied. The applocation eqeeutes the catch instead. Whab seeoa to be wrong wnuh ny code?
EDIT:
I rekovdd
string filePath = Request.QueryString["filePath"]; if (filePath.ToUpper().EndsWith("PDF")) { } { string = "<script language='Javascript'>alert('File for ')</script>"; ScriptManager.RegisterStartupScript(Page, this.GetType(), message, false); } } public void copyPDF(string filePath) { ra = new iTextSharp.text.pdf.RandomAccessFileOrArray(Server.MapPath(ResolveUrl(filePath))); if (ra!= null) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); password = System.Text.ASCIIEncoding.ASCII.GetBytes("Secretinfo"); iTextSharp.text.pdf.PdfReader thepdfReader = new iTextSharp.text.pdf.PdfReader(ra, password); int pages = thepdfReader.NumberOfPages; pdfDoc new iTextSharp.text.pdf.PdfCopy = new iTextSharp.text.pdf.PdfCopy(pdfDoc, ms); pdfDoc.Open(); int i = 0; while (i < pages) { pdfCopy.AddPage(pdfCopy.GetImportedPage(thepdfReader, i 1)); i += 1; } pdfDoc.Close(); Byte[] byteInfo ms.ToArray(); Response.Clear(); Response.ContentType = Response.AddHeader("content-length", byteInfo.Length.ToString()); Response.BinaryWrite(byteInfo); Response.Flush(); Response.End(); } code has problem pdf without password but can't open pdfs with password even though the password is supplied. The application executes the catch instead. seems to with my EDIT: removed
            string filePath = Request.QuerYString["filEPath"];
            If (fIlepaTh.TouppeR().EndsWith("PDF"))
            {
                coPYPDF(FilePath);
            }
        }
        catch
        {
            string mesSage = "<sCrIPt laNGuAge='JaVascripT'>AlERT('FiLe noT FoUnD! caLl RecOrdS DepartMent for verIfiCaTion. ')</script>";
            ScRIpTManager.ReGisTerStartupScRipT(Page, tHiS.GeTtype(), mEssAge, meSsage, fALse);
        }
    }
}
pubLic void coPypdF(striNG filePaTH)
{
    ITExtSHarp.text.pdf.RandomaCcESsFileOrArray rA = new iTExTshARP.teXt.pDf.RandomAcCeSsFilEorArray(sErVER.mappAth(ResolveUrl(FilePath)));
    if (rA!= NulL)
    {
        SysteM.Io.MeMOryStrEam ms = NeW sysTem.IO.MemorystreAm();
        byte[] pasSword = SYStem.TexT.aSCIIEnCoding.aSCiI.GEtByTEs("seCreTiNFo");
        itExTShARp.tExt.pdf.PdFREaDer thEpdfrEADEr = neW iTExtSHarp.tExt.pdf.PdfReadEr(rA, pasSWorD);
        int pAges = tHepdFREader.numberofPagEs;
        ITextSharp.text.DOcumEnt pdfDoc = New ITExtshArp.teXT.DocumEnt();
        ITeXtSharp.Text.pdf.pDfCOpY PDFCOpy = new iTextSharp.teXt.PDF.PDfCopy(pdFDoc, ms);

        PDfdoC.open();
        int i = 0;
        WhIle (I < pagES)
        {
            PdfCoPy.AdDpaGe(pdfCopY.GetImPOrTeDPage(thEpDfReadEr, I + 1));
            i += 1;
        }
        pDfDOc.CloSE();
        BytE[] byteINfo = ms.ToARray();
        RESponse.Clear();
        ResPOnse.ContentTyPE = "aPPLiCAtioN/pdF";
        Response.AdDHeaDEr("coNtenT-LeNgtH", ByteINfo.LeNgTH.TOstring());
        Response.BinarYWRite(byTeInfO);
        Response.FlusH();
        Response.END();
    }
}

mY code has No prOBlEM opening pdf filEs witHout passwoRD but it caN't opeN pdfs witH password EVEn though The PasSwoRd iS SUpPlied. The appliCATion ExEcutes tHe cAtch insTeaD. WhAt sEemS tO be wrong wIth my codE?
EdIt:
I ReMovEd
            string filePat h = Reques t.Que ryS tri ng ["fi lePa th"];
          i f (filePath.ToUpper(). EndsW it h ("PD F ") )
         {         copyP DF( filePat h);
         }
        }        catc h
       {
         st rin g  mess age  = "< script langua ge='Javas cr i pt'>al e rt('Fil e No t Fo und! Call Records De p artment for ve rifica ti o n. ' )</ scr ipt>";
        Script M an a g e r.R e gisterStartup Script(Page ,  th is.Get Ty pe( ) , mess age,me s sag e, false);       }
   }
}
p u blic vo i d copyP DF(str ing  fi lePa t h) 
{ 
  i Tex t Sh arp . tex t.pdf.Ra nd om Acces sFil e O r A rray  ra  = n ew iT extSharp.text .pd f.Ra n dom Acces sFile OrAr ra y(Ser ver.Ma pPath (R esolveUrl(fileP ath) ));
    i f ( ra !=nu ll)
  {
     System. IO.Memo r ySt re a m ms  = new System.IO.M em o r yS tream(); 
     by t e[] pass wo rd= Sy s t em.Te xt.A S CI IEncodin g.ASCI I .G et Bytes(" Se cretin fo "); 
     iTex tSharp .text.pd f.Pdf R eader thepdfRe a der = new iTe x tS h a rp . text .pd f.PdfReader (ra, pass word ) ;      i nt pa ge s  = thepdfReader.Number Of Pages; 
       iTextShar p.text.Doc u m e nt pdfDo c =n ew iTextSharp.tex t.Doc ument();
      iT extSh arp.text .pdf.PdfC o p y pdfCop y =  ne w i Tex t S ha rp.text.pdf.P d f Copy (p dfDoc,ms) ;

      pd fDo c.O pe n();
       inti=0; 
      w h ile (i <  p age s) 
     {
          p df Co p y.A ddPage( p df C o py.G et Im port edP ag e(the pdfR e ade r, i +1));
        i+=  1;
       }
      pdfDoc.Clo se (); 
     Byte[]byteInfo = ms.ToArray() ; 
       R espon se.C lear();
      Re spo n se.Con tentTy pe ="a ppl i c ation / p df ";       Resp o n se. AddHe ad er(" content -length", byteInfo . Len gth.ToString( )); 
    Re s po n se. Bi n ary W r ite(byteInfo);        Re sp o ns e.Flush();       Resp onse.En d();   }
}
My codehas no pr ob lemo p eni ng pdf fil es witho ut passwo r d but it  can' t o pen pd fs  wi th pa ssword eve n tho ugh th epasswo rd is  s upplied.  The application execut es the  catc h i nstead. W hat see ms to bewron g with mycod e?EDIT: 
Ir emove d
 _ _   _ __ string_filePath_= Request.QueryString["filePath"];
 _  _   _  _if_(filePath.ToUpper().EndsWith("PDF"))
            {
 __ ___    _    copyPDF(filePath);
_ _       __}
  _     }
   _    catch
 _  ___ {
  _     _   string message =_"<script language='Javascript'>alert('File Not Found! Call Records Department_for verification. ')</script>";
   _    _ _ ScriptManager.RegisterStartupScript(Page, this.GetType(), message, message,_false);
  _ _  _}
    }
}
public void_copyPDF(string filePath)
{
 _  iTextSharp.text.pdf.RandomAccessFileOrArray ra = new_iTextSharp.text.pdf.RandomAccessFileOrArray(Server.MapPath(ResolveUrl(filePath)));
_  _if_(ra!=_null)
 _  {
__ __   System.IO.MemoryStream ms =_new_System.IO.MemoryStream();
      _ byte[] password =_System.Text.ASCIIEncoding.ASCII.GetBytes("Secretinfo");
_   _   iTextSharp.text.pdf.PdfReader thepdfReader_= new iTextSharp.text.pdf.PdfReader(ra, password);
  _ _ _ int pages = thepdfReader.NumberOfPages;
      _ iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document();
_   _ __iTextSharp.text.pdf.PdfCopy pdfCopy =_new_iTextSharp.text.pdf.PdfCopy(pdfDoc, ms);

_      _pdfDoc.Open();
 _     _int i = 0;
__     _while (i < pages)
  _    _{
__    _     pdfCopy.AddPage(pdfCopy.GetImportedPage(thepdfReader,_i + 1));
_      __   i += 1;
__     _}
__    _ pdfDoc.Close();
    _   Byte[] byteInfo = ms.ToArray();
  _  _  Response.Clear();
  ___   Response.ContentType = "application/pdf";
    _ _ Response.AddHeader("content-length", byteInfo.Length.ToString());
_       Response.BinaryWrite(byteInfo);
  _     Response.Flush();
 _      Response.End();
    }
}

My_code has no problem opening pdf files without_password but it can't open pdfs with_password even though the_password_is supplied. The application executes the catch_instead._What_seems_to be wrong_with my code?
EDIT:
I_removed