when i upload a pdf file on button click it shows no of pages in that file on a label.
if the file size is more than 4 mb then it shows ===
This webpage is not available
The connection to localhost was interrupted.
Here are some suggestions:
- Reload this webpage later.
- Check your Internet connection. Restart any router, modem, or other network devices you may be using.
- Add Google Chrome as a permitted program in your firewall's or antivirus software's settings. If it is already a permitted program, try deleting it from the list of permitted programs and adding it again.
- If you use a proxy server, check your proxy settings or contact your network administrator to make sure the proxy server is working. If you don't believe you should be using a proxy server, adjust your proxy settings: Go to the Chrome menu >Settings > Show advanced settings... > Change proxy settings... > LAN Settings and deselect the "Use a proxy server for your LAN" checkbox.
My Codes to count no of Pages :
------------------------------------------
string fn = FileUpload1.FileName.ToString();
string extension = System.IO.Path.GetExtension(FileUpload1.FileName);
if (extension == ".pdf" || extension == ".PDF")
{
if (btnSubmit.Text == "Save")
{
GenerateFileName();
}
ViewState["directoryPath2"] = Server.MapPath("~/DMS_Data/" + Session["userDistCode"].ToString() + "/" + Session["userTehCode"].ToString() + "/");
FileUpload1.SaveAs(ViewState["directoryPath2"].ToString() + fn);
FileStream fs = new FileStream(ViewState["directoryPath2"].ToString() + fn, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
//string pdftext = sr.ReadToEnd();D:/DMS/DMS_Backup_App/120513/DMS/PDF_docs/
Regex _Regex = new Regex(@"/Type\s*/Page[^s]");
MatchCollection matches = _Regex.Matches(sr.ReadToEnd());
lblNoFPgs.Text = matches.Count.ToString();
Up.Visible = true;
lblUploaded.Text = fn;
}
else
{
string Msg = "<script>alert('Please select PDF files only !');</script>";
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", Msg, false);
FileUpload1.Focus();
}