public void getIndirectDictionaryArrayInDictionaryHex(ref List <string[]> value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { //NEEDS TO IMPLEMENT RECURSSIVE ARRAYS DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); offset = offset + keyLength + white_space_characters.SPACE.Hexadecimal.Length; string tmp = substringDelimiterRecurrent(stream, offset, delimiter_characters.LEFT_SQUARE_BRACKET.Hexadecimal, delimiter_characters.RIGHT_SQUARE_BRACKET.Hexadecimal); string substream = tmp.Trim('-'); substream = substream.Trim(white_space_characters.SPACE.Hexadecimal.ToCharArray()); substream = substream.Trim('-'); substream = substream.Trim(delimiter_characters.LEFT_SQUARE_BRACKET.Hexadecimal.ToCharArray()); substream = substream.Trim(delimiter_characters.RIGHT_SQUARE_BRACKET.Hexadecimal.ToCharArray()); substream = substream.Trim('-'); substream = substream.Trim(white_space_characters.LINE_FEED.Hexadecimal.ToCharArray()); substream = substream.Trim('-'); substream = lineHexToString(substream); string[] result = substream.Split(lineHexToString(white_space_characters.LINE_FEED.Hexadecimal).ToCharArray()); for (int i = 0; i < result.Length; i++) { string tmp_result = result[i]; string[] tmp2result = tmp_result.Split(lineHexToString(white_space_characters.SPACE.Hexadecimal).ToCharArray()); value.Add(tmp2result); } }
public void getBooleanInDictionaryHex(ref Boolean value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); offset = offset + keyLength + white_space_characters.SPACE.Hexadecimal.Length + 2; int[] idx = new int[17]; idx[0] = stream.IndexOf(delimiter_characters.GREATER_THAN_SIGN.Hexadecimal, offset); idx[1] = stream.IndexOf(delimiter_characters.LEFT_CURLY_BRACKET.Hexadecimal, offset); idx[2] = stream.IndexOf(delimiter_characters.LEFT_PARENTHESIS.Hexadecimal, offset); idx[3] = stream.IndexOf(delimiter_characters.LEFT_SQUARE_BRACKET.Hexadecimal, offset); idx[4] = stream.IndexOf(delimiter_characters.LESS_THAN_SIGN.Hexadecimal, offset); idx[5] = stream.IndexOf(delimiter_characters.PERCENT_SIGN.Hexadecimal, offset); idx[6] = stream.IndexOf(delimiter_characters.RIGHT_CURLY_BRACKET.Hexadecimal, offset); idx[7] = stream.IndexOf(delimiter_characters.RIGHT_PARENTHESIS.Hexadecimal, offset); idx[8] = stream.IndexOf(delimiter_characters.RIGHT_SQUARE_BRACKET.Hexadecimal, offset); idx[9] = stream.IndexOf(delimiter_characters.SOLIDUS.Hexadecimal, offset); idx[10] = stream.IndexOf(white_space_characters.CARRIAGE_RETURN.Hexadecimal, offset); idx[11] = stream.IndexOf(white_space_characters.EOF.Hexadecimal, offset); idx[12] = stream.IndexOf(white_space_characters.FORM_FEED.Hexadecimal, offset); idx[13] = stream.IndexOf(white_space_characters.HORIZONTAL_TAB.Hexadecimal, offset); idx[14] = stream.IndexOf(white_space_characters.LINE_FEED.Hexadecimal, offset); idx[15] = stream.IndexOf(white_space_characters.NULL.Hexadecimal, offset); idx[16] = stream.IndexOf(white_space_characters.SPACE.Hexadecimal, offset); int remove = -1; idx = idx.Where(val => val != remove).ToArray(); int my_idx = idx.Min(); string my_boolean_hexa = stream.Substring(offset, my_idx - offset); string my_boolean_string = lineHexToString(my_boolean_hexa); Boolean result = false; if (String.Compare(my_boolean_string, "true") == 0) { result = true; } value = result; }
public void getStringInDictionaryHex(ref string value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); offset = offset + keyLength + white_space_characters.SPACE.Hexadecimal.Length; int idx_lts = stream.IndexOf(delimiter_characters.LESS_THAN_SIGN.Hexadecimal, offset); int idx_lp = stream.IndexOf(delimiter_characters.LEFT_PARENTHESIS.Hexadecimal, offset); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// 7.3.4.2 Literal Strings ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ((idx_lp < idx_lts) && idx_lts != -1 && idx_lp != -1) { string tmp = substringDelimiterRecurrent(stream, offset, delimiter_characters.LEFT_PARENTHESIS.Hexadecimal, delimiter_characters.RIGHT_PARENTHESIS.Hexadecimal); ///////////////////////////////////////////////////////// /// Table 3 - Escape Sequences in Literal Strings ///////////////////////////////////////////////////////// /// it should convert to string ///////////////////////////////////////////////////////// value = lineHexToString(tmp); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// 7.3.4.3 Hexadecimal Strings ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if ((idx_lts < idx_lp) && idx_lp != -1 && idx_lts != -1) { int idx_gts = stream.IndexOf(delimiter_characters.GREATER_THAN_SIGN.Hexadecimal, offset); string tmp = stream.Substring(idx_lts, idx_gts - idx_lts); value = tmp; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// CHECK ERRORS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (idx_lp == -1 && idx_lts == -1) { //throw error } }
public void getDateInDictionaryHex(ref DateTime value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); offset = offset + keyLength + white_space_characters.SPACE.Hexadecimal.Length + 2; int[] idx = new int[17]; idx[0] = stream.IndexOf(delimiter_characters.GREATER_THAN_SIGN.Hexadecimal, offset); idx[1] = stream.IndexOf(delimiter_characters.LEFT_CURLY_BRACKET.Hexadecimal, offset); idx[2] = stream.IndexOf(delimiter_characters.LEFT_PARENTHESIS.Hexadecimal, offset); idx[3] = stream.IndexOf(delimiter_characters.LEFT_SQUARE_BRACKET.Hexadecimal, offset); idx[4] = stream.IndexOf(delimiter_characters.LESS_THAN_SIGN.Hexadecimal, offset); idx[5] = stream.IndexOf(delimiter_characters.PERCENT_SIGN.Hexadecimal, offset); idx[6] = stream.IndexOf(delimiter_characters.RIGHT_CURLY_BRACKET.Hexadecimal, offset); idx[7] = stream.IndexOf(delimiter_characters.RIGHT_PARENTHESIS.Hexadecimal, offset); idx[8] = stream.IndexOf(delimiter_characters.RIGHT_SQUARE_BRACKET.Hexadecimal, offset); idx[9] = stream.IndexOf(delimiter_characters.SOLIDUS.Hexadecimal, offset); idx[10] = stream.IndexOf(white_space_characters.CARRIAGE_RETURN.Hexadecimal, offset); idx[11] = stream.IndexOf(white_space_characters.EOF.Hexadecimal, offset); idx[12] = stream.IndexOf(white_space_characters.FORM_FEED.Hexadecimal, offset); idx[13] = stream.IndexOf(white_space_characters.HORIZONTAL_TAB.Hexadecimal, offset); idx[14] = stream.IndexOf(white_space_characters.LINE_FEED.Hexadecimal, offset); idx[15] = stream.IndexOf(white_space_characters.NULL.Hexadecimal, offset); idx[16] = stream.IndexOf(white_space_characters.SPACE.Hexadecimal, offset); int remove = -1; idx = idx.Where(val => val != remove).ToArray(); int my_idx = idx.Min(); string my_date = stream.Substring(offset, my_idx - offset); my_date = my_date.Trim('-'); string date_string = lineHexToString(my_date); DateTime time = Convert.ToDateTime(date_string); value = time; }
public void getArrayInDictionaryHex(ref List <string> value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); offset = offset + keyLength + white_space_characters.SPACE.Hexadecimal.Length; string tmp = substringDelimiterRecurrent(stream, offset, delimiter_characters.LEFT_SQUARE_BRACKET.Hexadecimal, delimiter_characters.RIGHT_SQUARE_BRACKET.Hexadecimal); string substream = tmp.Trim('-'); substream = substream.Trim(white_space_characters.SPACE.Hexadecimal.ToCharArray()); substream = substream.Trim('-'); substream = lineHexToString(substream); string[] result = substream.Split(white_space_characters.SPACE.Hexadecimal.ToCharArray()); value.AddRange(result); }
public void getFunctionArrayInDictionaryHex(ref List <PDF_Function> value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); offset = offset + keyLength + white_space_characters.SPACE.Hexadecimal.Length + 2; int[] idx = new int[17]; idx[0] = stream.IndexOf(delimiter_characters.GREATER_THAN_SIGN.Hexadecimal, offset); idx[1] = stream.IndexOf(delimiter_characters.LEFT_CURLY_BRACKET.Hexadecimal, offset); idx[2] = stream.IndexOf(delimiter_characters.LEFT_PARENTHESIS.Hexadecimal, offset); idx[3] = stream.IndexOf(delimiter_characters.LEFT_SQUARE_BRACKET.Hexadecimal, offset); idx[4] = stream.IndexOf(delimiter_characters.LESS_THAN_SIGN.Hexadecimal, offset); idx[5] = stream.IndexOf(delimiter_characters.PERCENT_SIGN.Hexadecimal, offset); idx[6] = stream.IndexOf(delimiter_characters.RIGHT_CURLY_BRACKET.Hexadecimal, offset); idx[7] = stream.IndexOf(delimiter_characters.RIGHT_PARENTHESIS.Hexadecimal, offset); idx[8] = stream.IndexOf(delimiter_characters.RIGHT_SQUARE_BRACKET.Hexadecimal, offset); idx[9] = stream.IndexOf(delimiter_characters.SOLIDUS.Hexadecimal, offset); idx[10] = stream.IndexOf(white_space_characters.CARRIAGE_RETURN.Hexadecimal, offset); idx[11] = stream.IndexOf(white_space_characters.EOF.Hexadecimal, offset); idx[12] = stream.IndexOf(white_space_characters.FORM_FEED.Hexadecimal, offset); idx[13] = stream.IndexOf(white_space_characters.HORIZONTAL_TAB.Hexadecimal, offset); idx[14] = stream.IndexOf(white_space_characters.LINE_FEED.Hexadecimal, offset); idx[15] = stream.IndexOf(white_space_characters.NULL.Hexadecimal, offset); idx[16] = stream.IndexOf(white_space_characters.SPACE.Hexadecimal, offset); int remove = -1; idx = idx.Where(val => val != remove).ToArray(); int my_idx = idx.Min(); string result = stream.Substring(offset, my_idx - offset); List <PDF_Function> pdf_functions = new List <PDF_Function>(); value = pdf_functions; }
public void getIndirectDictionaryArrayWithNamesInDictionaryHex(ref Dictionary <string, string[]> value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); string LTS_double = delimiter_characters.LESS_THAN_SIGN.Hexadecimal + '-' + delimiter_characters.LESS_THAN_SIGN.Hexadecimal; string GTS_double = delimiter_characters.GREATER_THAN_SIGN.Hexadecimal + '-' + delimiter_characters.GREATER_THAN_SIGN.Hexadecimal; string tmp = substringDelimiterRecurrent(stream, offset, LTS_double, GTS_double); string substream = tmp.Trim('-'); substream = substream.Trim(white_space_characters.SPACE.Hexadecimal.ToCharArray()); substream = substream.Trim('-'); substream = substream.Trim(delimiter_characters.LEFT_SQUARE_BRACKET.Hexadecimal.ToCharArray()); substream = substream.Trim(delimiter_characters.RIGHT_SQUARE_BRACKET.Hexadecimal.ToCharArray()); substream = substream.Trim('-'); substream = substream.Trim(white_space_characters.LINE_FEED.Hexadecimal.ToCharArray()); substream = substream.Trim('-'); substream = substream.Trim(LTS_double.ToCharArray()); substream = substream.Trim(GTS_double.ToCharArray()); substream = lineHexToString(substream); string[] _separator = new string[] { white_space_characters.LINE_FEED.Glyph }; string[] result = substream.Split(_separator, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < result.Length; i = i + 2) { string tmp_result = result[i]; string tmp2_result = result[i + 1]; string[] tmp2result = tmp2_result.Split(lineHexToString(white_space_characters.SPACE.Hexadecimal).ToCharArray()); value.Add(tmp_result, tmp2result); } }
private static void Main(String[] args) { string[] arg = new string[3]; arg[0] = Convert.ToString(1000); //arg[1] = "C:\\Users\\Dornas\\Dropbox\\__ D - BE-HAPPY\\3. CEO\\1. ONTOLOGY\\HQ - Projects (IN)\\_KNOWLEDGE_CENTER\\_DOC\\pdf_test.pdf"; arg[1] = "C:\\Users\\Dornas\\Dropbox\\__ D - BE-HAPPY\\y. HARD-QUALE\\_PROJECT (IN)\\_KNOWLEDGE-CENTER\\_DOC\\_ADOBE\\pdf_example.pdf"; //arg[2] = "no_debug"; arg[2] = "debug"; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// GLOBAL VARIABLES, CONSTANTS AND TOOLS FUNCTIONS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Globals globals = new Globals(); Syntax syntax = new Syntax(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); string LF = white_space_characters.LINE_FEED.Hexadecimal; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// PARSE ARGUMENTS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// parse(arg, ref globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// LOAD FILE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// loadFile(ref globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// FILE HEADER ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// syntax.file_structure.File_Header(ref globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// FILE TRAILER ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// syntax.file_structure.File_Trailer(ref globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// CROSS REFERENCE TABLE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// globals.PDF_Cross_Reference_Table = new PDF_Cross_Reference_Table[globals.PDF_Properties.nObjects]; syntax.file_structure.Cross_Reference_Table(ref globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// CROSS REFERENCE STREAM ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* * if (globals.PDF_Properties.pdf_version_f > globals.PDF_Versions.v15) * { * globals.PDF_Cross_Reference_Stream = new PDF_Cross_Reference_Stream[globals.PDF_Properties.nObjects]; * * syntax.file_structure.Cross_Reference_Streams(ref globals); * } */ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// DOCUMENT CATALOG ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// syntax.document_structure.Document_Catalog(ref globals); //readObjects(ref globals, LF); }
private static void loadFile(ref Globals globals) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //CARREGA O ARQUIVO DO DISCO //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// tools Tools = new tools(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); byte[] pdf_stream = new byte[(int)Math.Ceiling(globals.PDF_Plugin_Properties.max_pdf_file_size)]; globals.PDF_File.pdf_stream_hexa = new string('-', (int)Math.Ceiling(globals.PDF_Plugin_Properties.max_pdf_file_size)); if (File.Exists(globals.PDF_File.fileNamePath)) { using (BinaryReader reader = new BinaryReader(File.Open(globals.PDF_File.fileNamePath, FileMode.Open))) { pdf_stream = reader.ReadBytes((int)globals.PDF_File.fileSize); globals.PDF_File.pdf_stream_hexa = BitConverter.ToString(pdf_stream, 0); } if (globals.PDF_Plugin_Properties.debug) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //ESSA PARTE DO CODIGO EH APENAS PARA TESTES //DEVO USAR APENAS O STREAM HEXA //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// globals.PDF_File.pdf_stream_string = new string('-', (int)Math.Ceiling(globals.PDF_Plugin_Properties.max_pdf_file_size)); globals.PDF_File.pdf_stream_string = Tools.lineHexToString(globals.PDF_File.pdf_stream_hexa); Syntax syntax = new Syntax(); string CR = white_space_characters.CARRIAGE_RETURN.Hexadecimal; string LF = white_space_characters.LINE_FEED.Hexadecimal; string CR_s = Tools.lineHexToString(CR); string LF_s = Tools.lineHexToString(LF); string[] CR_separator = new string[] { CR_s }; string[] LF_separator = new string[] { LF_s }; string[] _lines_string = globals.PDF_File.pdf_stream_string.Split(CR_separator, StringSplitOptions.None); List <string> allLines = new List <string>(); for (int i = 0; i < _lines_string.Length; i++) { string[] new_lines_string = _lines_string[i].Split(LF_separator, StringSplitOptions.None); for (int j = 0; j < new_lines_string.Length; j++) { if (String.IsNullOrEmpty(new_lines_string[j]) != true) { allLines.Add(new_lines_string[j]); } } } globals.PDF_File.pdf_lines_string = new List <string>(); globals.PDF_File.pdf_lines_hexa = new List <string>(); for (int i = 0; i < allLines.Count; i++) { string line_string = allLines[i]; string line_hexa = Tools.lineStringToHex(line_string); globals.PDF_File.pdf_lines_hexa.Add(line_hexa); globals.PDF_File.pdf_lines_string.Add(line_string); } globals.PDF_Properties.nLines = globals.PDF_File.pdf_lines_string.Count; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } } }
public int identifyObject(ref Globals globals, ref string stream_hexa, int offset) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); int[] idx = new int[2]; string stream_string = lineHexToString(stream_hexa); idx[0] = stream_hexa.IndexOf(white_space_characters.CARRIAGE_RETURN.Hexadecimal, offset); idx[1] = stream_hexa.IndexOf(white_space_characters.LINE_FEED.Hexadecimal, offset); int idx_min = idx.Min(); string line = lineHexToString(stream_hexa.Substring(offset, idx_min - offset)); string LP = delimiter_characters.LEFT_PARENTHESIS.Glyph; string LT = delimiter_characters.LESS_THAN_SIGN.Glyph; string SL = delimiter_characters.SOLIDUS.Glyph; string LS = delimiter_characters.LEFT_SQUARE_BRACKET.Glyph; char LP_c = LP[0]; char LT_c = LT[0]; char SL_c = SL[0]; char LS_c = LS[0]; string keyword_stream = "stream"; string keyword_null = "null"; string keyword_obj = "obj"; int kindOfObject = -1; string[] keys = line.Split(' '); string firstKey = keys[0]; Boolean isNumeric = float.TryParse(keys[0], out float nfloat); if ((isNumeric == false) && ((String.Compare(firstKey, "true") == 0) || (String.Compare(firstKey, "false") == 0))) { kindOfObject = globals.Kinds_of_Objects.Boolean; //7.3.2 Boolean Objects } else if (isNumeric) { kindOfObject = globals.Kinds_of_Objects.Numeric; //7.3.3 Numeric Objects } else if ((isNumeric == false) && (firstKey[0] == LP_c) || ((isNumeric == false) && (firstKey[0] == LT_c) && (firstKey[1] != LT_c))) { kindOfObject = globals.Kinds_of_Objects.String; //7.3.4 String Objects } else if ((isNumeric == false) && (firstKey[0] == SL_c)) { kindOfObject = globals.Kinds_of_Objects.Name; //7.3.5 Name Objects } else if ((isNumeric == false) && (firstKey[0] == LS_c)) { kindOfObject = globals.Kinds_of_Objects.Array; //7.3.6 Array Objects } else if ((isNumeric == false) && (firstKey[0] == LT_c) && (firstKey[1] == LT_c)) { kindOfObject = globals.Kinds_of_Objects.Dictionary; //7.3.7 Dictionary Objects } else if ((isNumeric == false) && (String.Compare(firstKey, keyword_stream) == 0)) { kindOfObject = globals.Kinds_of_Objects.Stream; //7.3.8 Stream Objects } else if ((isNumeric == false) && (String.Compare(firstKey, keyword_null) == 0)) { kindOfObject = globals.Kinds_of_Objects.Null; //7.3.9 Null Object } else if ((isNumeric == true) && (String.Compare(keys[2], keyword_obj) == 0)) { kindOfObject = globals.Kinds_of_Objects.Indirect; //7.3.10 Indirect Objects } if (kindOfObject == globals.Kinds_of_Objects.Dictionary) { int idx_lts = stream_string.IndexOf(LT_c); int idx_l_feed = stream_string.IndexOf(white_space_characters.SPACE.Glyph, idx_lts + 3); string tmp = stream_string.Substring(idx_lts + 3, idx_l_feed - idx_lts - 3); if (String.Compare(tmp, "/FunctionType") == 0) { kindOfObject = globals.Kinds_of_Objects.Functions; } } return(kindOfObject); }
public void getMatrixInDictionaryHex(ref List <List <float> > value, ref string stream, int offset, int keyLength, ref int ERROR_ID, ref string ERROR_MSG) { DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); }
private static void Main(String[] args) { string[] arg = new string[4]; arg[0] = Convert.ToString(1000); //arg[1] = "file"; arg[1] = "directory"; //arg[2] = "C:\\Users\\Dornas\\Dropbox\\__ D - BE-HAPPY\\3. CEO\\1. ONTOLOGY\\HQ - Projects (IN)\\_KNOWLEDGE_CENTER\\_DOC\\pdf_test.pdf"; //arg[2] = "C:\\Users\\Dornas\\Dropbox\\__ D - BE-HAPPY\\y. HARD-QUALE\\_PROJECT (IN)\\_KNOWLEDGE-CENTER\\_DOC\\_ADOBE\\pdf_example.pdf"; arg[2] = "C:\\Users\\Dornas\\Dropbox\\__ XX - HARD-QUALE\\_KNOWLEDGE-CENTER\\_DOCUMENT_DATABASES\\RETINA"; //arg[2] = "C:\\Users\\Dornas\\Dropbox\\__ XX - HARD-QUALE\\_KNOWLEDGE-CENTER\\_DOCUMENT_DATABASES\\RETINA\\27928387_pmc.pdf"; arg[3] = "no_debug"; //arg[3] = "debug"; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// GLOBAL VARIABLES, CONSTANTS AND TOOLS FUNCTIONS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// tools Tools = new tools(); Globals Globals = new Globals(); Syntax Syntax = new Syntax(); WHITE_SPACE_CHARACTERS white_space_characters = new WHITE_SPACE_CHARACTERS(); DELIMITER_CHARACTERS delimiter_characters = new DELIMITER_CHARACTERS(); string LF = white_space_characters.LINE_FEED.Hexadecimal; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// PARSE ARGUMENTS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Tools.parse(arg, ref Globals); List <string> filesNames = new List <string>(); if (String.Compare(arg[1], "file") == 0) { filesNames.Add(Globals.PDF_File.fileNamePath); } else if (String.Compare(arg[1], "directory") == 0) { filesNames.AddRange(Directory.GetFiles(Globals.PDF_File.directoryPath, "*.pdf")); } int iFile = 0; foreach (string fileNamePath in filesNames) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// LOAD FILE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// iFile = iFile + 1; Globals.PDF_File.fileNamePath = fileNamePath; Globals.PDF_Properties.byte_offset_xref = new List <int>(); Globals.PDF_Properties.byte_offset_xref_kind = new List <int>(); if (Globals.PDF_Plugin_Properties.debug) { Console.WriteLine(Convert.ToString(iFile)); } ; Console.WriteLine(Convert.ToString(iFile)); if (iFile >= 28869) //if (iFile >= 0) { Tools.loadFile(ref Globals); string html = "!DOCTYPE html"; int idx = Globals.PDF_File.pdf_stream_hexa.IndexOf(Tools.lineStringToHex(html)); if (idx == 0) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// FILE HEADER ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Syntax.file_structure.File_Header(ref Globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// FILE TRAILER ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Syntax.file_structure.File_Trailer(ref Globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// CROSS REFERENCE TABLE ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// PDF_Cross_Reference_Table[] cross = new PDF_Cross_Reference_Table[Globals.PDF_Properties.nObjects]; Globals.PDF_Cross_Reference_Table = new List <PDF_Cross_Reference_Table>(Globals.PDF_Properties.nObjects); Globals.PDF_Cross_Reference_Table.AddRange(cross); Syntax.file_structure.Cross_Reference_Table_or_Stream(ref Globals); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// DOCUMENT CATALOG ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int iroot = 0; for (int i = 0; i < Globals.PDF_Trailer.Count; i++) { if (Convert.ToInt16(Globals.PDF_Trailer[i].Root.value[0]) > 0) { iroot = Convert.ToInt16(Globals.PDF_Trailer[i].Root.value[0]); } } int root_offset = Globals.PDF_Cross_Reference_Table[iroot].byte_offset * 3; Syntax.document_structure.getDocumentCatalog(ref Globals, root_offset); } else if (idx != -1) { Tools.saveDebugInfo(ref Globals, "html", "HTML"); } Globals.PDF_Properties.byte_offset_xref.Clear(); Globals.PDF_Properties.byte_offset_xref_kind.Clear(); Globals.PDF_Trailer.Clear(); } /* * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * /// PAGE TREE * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * * Syntax.document_structure.getPageTree(ref Globals); * * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * /// PAGES * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * * custom_value<object> kids_obj = (custom_value<object>)Globals.PDF_Page_Tree["/Kids"]; * * List<string[]> kids = (List<string[]>)kids_obj.value; * * Globals.PDF_Properties.nPages = kids.Count; * * int nKids = kids.Count; * * for (int iPage = 0; iPage < nKids; iPage++) * { * string[] obj = kids[iPage]; * * int iPageObj = Convert.ToInt16(obj[0]); * * int offset = Globals.PDF_Cross_Reference_Table[iPageObj].byte_offset * 3; * * Syntax.document_structure.getPages(ref Globals, offset); * } * * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * /// PAGES - CONTENTS * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * * Syntax.content_streams_and_resources.getPagesContents(ref Globals); * * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * /// PAGES - RESOURCES - EXTGSTATE * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * * for (int iPage = 0; iPage < Globals.PDF_Properties.nPages; iPage++) * { * Syntax.content_streams_and_resources.getResourceExtGState(ref Globals, iPage); * } * * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * /// PAGES - RESOURCES - FONT * ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// * * for (int iPage = 0; iPage < Globals.PDF_Properties.nPages; iPage++) * { * Syntax.content_streams_and_resources.getResourceFont(ref Globals, iPage); * } * * int x = 0; */ } }