this.textBox1.Text = fbd.SelectedPath.ToString();
DirectoryInfo directory = new DirectoryInfo(this.textBox1.Text.Trim());
FileInfo fileitem = new FileInfo(directory.GetFiles()[0].FullName);
FileStream fs = File.OpenRead(fileitem.FullName);
StreamReader r = new StreamReader(fs);
string pdfText = r.ReadToEnd();
Regex rx1 = new Regex(@"/Type/s*/Page[^s]");//正则
MatchCollection matches = rx1.Matches(pdfText);
MessageBox.Show("The PDF file has " + matches.Count.ToString() + " page(s).");
通过正则获得pdf页数
最新推荐文章于 2020-10-10 16:36:28 发布