/// <summary> /// Parsing data of pdf-file from tables /// </summary> internal void ParsingFile() { stream.Position = 0; using (var reader = new PdfReader(stream)) using (var pdf = new PdfDocument(reader)) { reader.SetCloseStream(false); PageCount = pdf.GetNumberOfPages(); // get every page for analyse PdfPage[] pages = Enumerable .Range(0, PageCount) .Select(t => pdf.GetPage(t + 1)) .ToArray(); // data of every page (two diferent variants) HeadInfo = ParsingHeader(pages[0]); // find the limits { Regex regex = new Regex(@"З(\s*)а(\s*)д(\s*)а(\s*)н(\s+)д(\s*)и(\s*)а(\s*)п(\s*)а(\s*)з(\s*)о(\s*)н(\s+)т(\s*)е(\s*)м(\s*)п(\s*)е(\s*)р(\s*)а(\s*)т(\s*)у(\s*)р(\s+)м(\s*)е(\s*)ж(\s*)д(\s*)у(\s*):(\s+[+-]?\d+)°C и(\s+[+-]?\d+)°C", RegexOptions.IgnoreCase | RegexOptions.Compiled); Match match = regex.Match(HeadInfo.ToString()); string findS = match.Value; regex = new Regex(@"([+-]?\d+)", RegexOptions.Compiled); MatchCollection matches = regex.Matches(findS); List <float> results = new List <float>(); foreach (Match m in matches) { float.TryParse(m.Value, out float res); results.Add(res); } // save data LimitMin = results.Min(); LimitMax = results.Max(); } //TODO: delete last row for last page, when we will be create new pdf-file // data of names every columns ColumnInfo = ParsingColumns(pages[0]); // data from tables DataInfo = new StringBuilder[PageCount - 1]; // analyse tables all page without last using multithreading Parallel.For(0, DataInfo.Length, i => DataInfo[i] = ParsingTables(pages[i])); // convert string data to real data TableData = ExtractTableData(DataInfo); // save data TableDataBlock = new KeyValuePairTable <int, DateTime, float, bool> [TableData.Length]; TableData.CopyTo(TableDataBlock, 0); // data of Oy axis OyAxisInfo = ParsingOyAxis(pages[PageCount - 1]); // convert string data to real data DataOyAxis = ExtractOyAxis(OyAxisInfo); // data of Ox axis OxAxisInfo = ParsingOxAxis(pages[PageCount - 1]); // convert string data to real data DataOxAxis = ExtractOxAxis(OxAxisInfo); pdf.Close(); } }