public PdfTrailer ReadTrailer() { var eofPos = _document.FindReverse(_document.Keywords.EOFLine); var startxrefPos = _document.FindReverse(_document.Keywords.StartXRefLine, eofPos); var startxrefData = _document.Encoding.GetString(_document.Read(startxrefPos + 11, eofPos - (startxrefPos + 11))); var trailerPos = _document.FindReverse(_document.Keywords.TrailerLine, startxrefPos) + 1; var result = new PdfTrailer { Offset = trailerPos, Length = eofPos - trailerPos, CrossReferenceTableOffset = int.Parse(startxrefData), Document = _document }; result.TrailerDictionary = _ReadDictionary(trailerPos + 8, result); return(result); }
internal static int FindReverse(this IEditablePdfDocument document, byte[] lookFor, int start) => document.FindReverse(lookFor.Length, w => w.ByteEquals(lookFor), start);
internal static int FindReverse(this IEditablePdfDocument document, byte[] lookFor) => document.FindReverse(lookFor, document.Length - 1);
internal static int FindReverse(this IEditablePdfDocument document, int windowSize, Func <byte[], bool> matches) => document.FindReverse(windowSize, matches, document.Length - 1);