static public void CompressPdfFile()
        {
            string pdfString = GetTextFromPdfFile();

            HuffmanTree huffmanTree = new HuffmanTree();

            Console.WriteLine("Pdf File Read Successfully\n");

            // Build the Huffman tree
            huffmanTree.Build_Tree(pdfString);

            // Encode the input file in BitArray in binary form
            BitArray bit_array = huffmanTree.Encode(pdfString);

            // Byte array for storing the bits from BitArray to save in bin file
            byte[] bytes = new byte[bit_array.Length / 8 + (bit_array.Length % 8 == 0 ? 0 : 1)];
            bit_array.CopyTo(bytes, 0);

            // write all the bits from byte array in bin file
            File.WriteAllBytes(BinaryFile, bytes);

            Console.Write("Pdf File Encoded Successfully\n");

            // Decode the bin file and write in pdf file
            // read all the bytes from binary file
            byte[] bytes2   = File.ReadAllBytes(BinaryFile);
            var    bitarray = new BitArray(bytes2);

            // decode the huffman tree
            string decoded = huffmanTree.Decode(bitarray);

            // write the decoded file in pdf file
            iTextSharp.text.Document oDoc = new iTextSharp.text.Document();
            PdfWriter.GetInstance(oDoc, new FileStream("C:/Users/Rehman Ali/Desktop/abcd.pdf", FileMode.Create));
            oDoc.Open();
            oDoc.Add(new iTextSharp.text.Paragraph(decoded));
            oDoc.Close();

            Console.WriteLine("Pdf File Decoded Successfuly\n");
        }
        // function for compressing the .txt extension file
        static public void CompressTextFile()
        {
            //Read the text file in string variable
            string inputFile = File.ReadAllText(textFile);

            HuffmanTree huffmanTree = new HuffmanTree();        // build new Huffman Tree

            Console.WriteLine("Text File Read Successfully\n");

            // Build the Huffman tree
            huffmanTree.Build_Tree(inputFile);

            // Encode the input file in BitArray in binary form
            BitArray bit_array = huffmanTree.Encode(inputFile);

            // Byte array for storing the bits from BitArray to save in bin file
            byte[] bytes = new byte[bit_array.Length / 8 + (bit_array.Length % 8 == 0 ? 0 : 1)];
            bit_array.CopyTo(bytes, 0);

            // write all the bits from byte array in bin file
            File.WriteAllBytes(BinaryFile, bytes);
            Console.Write("Text File Encoded Successfully\n");
            Console.WriteLine();

            // Decode the bin file and write in txt file
            // read all the bytes from binary file
            byte[] bytes2   = File.ReadAllBytes(BinaryFile);
            var    bitarray = new BitArray(bytes2);

            // decode the huffman tree
            string decoded = huffmanTree.Decode(bitarray);

            // write the decoded file in txt file
            File.WriteAllText(decompressedFile, decoded);
            Console.WriteLine("Text File Decoded Successfuly\n");
        }