Exemple #1
0
        private static void readObjects(ref Globals globals, string LF)
        {
            tools Tools = new tools();

            int nObjs = globals.PDF_Properties.nObjects;

            for (int i = 0; i < nObjs; i++)
            {
                if (globals.PDF_Cross_Reference_Table[i].in_use)
                {
                    int offset = globals.PDF_Cross_Reference_Table[i].byte_offset * 3;

                    string   line_hexa   = Tools.getLineFromByteOffset(ref globals.PDF_File.pdf_stream_hexa, offset, LF);
                    string   line_string = Tools.lineHexToString(line_hexa);
                    string[] keys        = line_string.Split(' ');
                    int      obj_idx     = Convert.ToInt32(keys[0]);

                    if (obj_idx == Convert.ToInt32(globals.PDF_Trailer.Root.value[0])) //ROOT CATALOG
                    {
                        while (true)
                        {
                            offset = offset + line_hexa.Length + 3;

                            line_hexa   = Tools.getLineFromByteOffset(ref globals.PDF_File.pdf_stream_hexa, offset, LF);
                            line_string = Tools.lineHexToString(line_hexa);
                        }
                    }
                    else
                    {
                        offset = offset + line_hexa.Length + 3;

                        line_hexa   = Tools.getLineFromByteOffset(ref globals.PDF_File.pdf_stream_hexa, offset, LF);
                        line_string = Tools.lineHexToString(line_hexa);
                    }
                }
            }
        }
Exemple #2
0
        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;

                    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                }
            }
        }