public static PdfXRefEntry Parse(int objectNumber, Lexical.ILexer lexer) { string offsetS = lexer.ReadToken(); if (offsetS.Length != 10) throw new Exception("Parser error: 10 digits expected for offset in xref"); long offset = long.Parse(offsetS); string generationS = lexer.ReadToken(); if (generationS.Length != 5) throw new Exception("Parser error: 5 digits expected for generation in xref"); int generationNumber = int.Parse(generationS); string inuse = lexer.ReadToken(); if (inuse != "f" && inuse != "n") throw new Exception("Parser error: only 'f' and 'n' are valid flags in xref"); bool inUse = (inuse == "n"); return new PdfXRefEntry(objectNumber, generationNumber, offset, inUse); }
public static PdfHexadecimalString Parse(Lexical.ILexer lexer) { StringBuilder hexString = new StringBuilder(); String text = string.Empty; while (text != ">") { hexString.Append(text); text = lexer.ReadToken(); } if ((hexString.Length % 2) != 0) hexString.Append('0'); return new PdfHexadecimalString(hexString.ToString()); }
public static PdfName Parse(Lexical.ILexer lexer) { String name = lexer.ReadToken(); return new PdfName(name); }