public void Load(string path) { this.path=path; PdfFile pf=new PdfFile(File.OpenRead(path)); pf.ProgressEvent+=new ProgressDelegate(pf_ProgressEvent); pf.Load(); this.MaxPage=pf.PageCount; }
public void Add(Stream PdfInputStream, int[] PageNumbers) { PdfFile pf = new PdfFile(PdfInputStream); pf.ProgressEvent+=new ProgressDelegate(pf_ProgressEvent); pf.Load(); PdfSplitter ps = new PdfSplitter(); ps.ProgressEvent+=new ProgressDelegate(pf_ProgressEvent); ps.Load(pf, PageNumbers, this.number); this.Add(ps); }
internal static PdfFileObject Create(PdfFile PdfFile, int number, long address) { PdfFileObject pfo = new PdfFileObject(); pfo.PdfFile = PdfFile; pfo.number = number; pfo.address = address; pfo.GetLenght(PdfFile); pfo.LoadText(); if (pfo.Type == PdfObjectType.Stream) { pfo = new PdfFileStreamObject(pfo); } pfo.filterEval = new MatchEvaluator(pfo.FilterEval); return(pfo); }
internal void Load(PdfFile PdfFile,int[] PageNumbers, int startNumber) { this.PdfFile = PdfFile; this.pageNumbers = new ArrayList(); this.sObjects = new Hashtable(); int part=0; int total=PageNumbers.Length; foreach (int PageNumber in PageNumbers) { this.ProgressEvent(part,total); PdfFileObject page = PdfFile.PageList[PageNumber] as PdfFileObject; page.PopulateRelatedObjects(PdfFile, this.sObjects); this.pageNumbers.Add(page.number); part++; } this.transHash = this.CalcTransHash(startNumber); foreach (PdfFileObject pfo in this.sObjects.Values) { pfo.Transform(transHash); } }
internal void Load(PdfFile PdfFile, int[] PageNumbers, int startNumber) { this.PdfFile = PdfFile; this.pageNumbers = new ArrayList(); this.sObjects = new Hashtable(); int part = 0; int total = PageNumbers.Length; foreach (int PageNumber in PageNumbers) { this.ProgressEvent(part, total); PdfFileObject page = PdfFile.PageList[PageNumber] as PdfFileObject; page.PopulateRelatedObjects(PdfFile, this.sObjects); this.pageNumbers.Add(page.number); part++; } this.transHash = this.CalcTransHash(startNumber); foreach (PdfFileObject pfo in this.sObjects.Values) { pfo.Transform(transHash); } }
internal void PopulateRelatedObjects(PdfFile PdfFile, Hashtable container) { if (!container.ContainsKey(this.number)) { container.Add(this.number, this); Match m = Regex.Match(this.text, @"(?'parent'(/Parent)*)\s*(?'id'\d+) 0 R[^G]", RegexOptions.ExplicitCapture); while (m.Success) { int num = int.Parse(m.Groups["id"].Value); bool notparent = m.Groups["parent"].Length == 0; if (notparent & !container.Contains(num)) { PdfFileObject pfo = PdfFile.LoadObject(num); if (pfo != null & !container.Contains(pfo.number)) { pfo.PopulateRelatedObjects(PdfFile, container); } } m = m.NextMatch(); } } }
private void GetLenght(PdfFile PdfFile) { Stream stream = PdfFile.memory; stream.Seek(this.address, SeekOrigin.Begin); Match m = Regex.Match("", @"endobj\s*"); int b = 0; this.length = 0; string word = ""; while (b != -1) { b = stream.ReadByte(); this.length++; if (b > 97 && b < 112) { char c = (char)b; word += c; if (word == "endobj") { b = -1; } } else { word = ""; } } char c2 = (char)stream.ReadByte(); while (Regex.IsMatch(c2.ToString(), @"\s")) { this.length++; c2 = (char)stream.ReadByte(); } }
internal static PdfFileObject Create(PdfFile PdfFile, int number, long address) { PdfFileObject pfo = new PdfFileObject(); pfo.PdfFile = PdfFile; pfo.number = number; pfo.address = address; pfo.GetLenght(PdfFile); pfo.LoadText(); if (pfo.Type == PdfObjectType.Stream) { pfo = new PdfFileStreamObject(pfo); } pfo.filterEval=new MatchEvaluator(pfo.FilterEval); return pfo; }
private void GetLenght(PdfFile PdfFile) { Stream stream = PdfFile.memory; stream.Seek(this.address, SeekOrigin.Begin); Match m = Regex.Match("", @"endobj\s*"); int b = 0; this.length = 0; string word = ""; while (b != -1) { b = stream.ReadByte(); this.length++; if (b > 97 && b < 112) { char c = (char)b; word += c; if (word == "endobj") b = -1; } else { word = ""; } } char c2 = (char)stream.ReadByte(); while (Regex.IsMatch(c2.ToString(), @"\s")) { this.length++; c2 = (char)stream.ReadByte(); } }
internal void PopulateRelatedObjects(PdfFile PdfFile,Hashtable container) { if (!container.ContainsKey(this.number)) { container.Add(this.number, this); Match m = Regex.Match(this.text, @"(?'parent'(/Parent)*)\s*(?'id'\d+) 0 R[^G]", RegexOptions.ExplicitCapture); while (m.Success) { int num = int.Parse(m.Groups["id"].Value); bool notparent = m.Groups["parent"].Length == 0; if (notparent & !container.Contains(num)) { PdfFileObject pfo = PdfFile.LoadObject(num); if (pfo != null & !container.Contains(pfo.number)) { pfo.PopulateRelatedObjects(PdfFile, container); } } m = m.NextMatch(); } } }