private MemoryStream CreatePreviewFax(StringCollection _listOfPdfs)
        {
            O2S.Components.PDF4NET.PDFDocument _ToBeCopiedPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFDocument _newPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFPage _pdfPage;
            Stream _fileStream = null;

            _ToBeCopiedPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
            _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

            for (int i = 0; i < _listOfPdfs.Count; i++)
            {
               // MakeDocumentReadable(_listOfPdfs[i]);
                _fileStream = new FileStream(Walden.CompleteFax.Library.Database.TemporaryFaxPath + GetUserName() + "\\" + _listOfPdfs[i], FileMode.Open);
                _ToBeCopiedPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_fileStream);

                for (int j = 0; j < _ToBeCopiedPDF.Pages.Count; j++)
                {
                    _pdfPage = _ToBeCopiedPDF.Pages[j];
                    _newPDF.Pages.Add(_pdfPage);
                }
                _fileStream.Close();
            }

            MemoryStream _newPDFStream = new MemoryStream();
            _newPDF.Save(_newPDFStream);

            return _newPDFStream;
        }
        public static bool DeleteMultiplePDFPagesV2(string _reviewDoc, int iStartPageToDelete)
        {
            try
            {
                int _constant = 0;
                int _pageCount = 0;

                O2S.Components.PDF4NET.PDFDocument _newPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_reviewDoc);
                _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
                iStartPageToDelete = iStartPageToDelete - 1;
                _constant = iStartPageToDelete;
                _pageCount = _newPDF.Pages.Count - 1;
                for (int i = iStartPageToDelete; i <= _pageCount; i++)
                {
                    _newPDF.Pages.RemoveAt(_constant);
                }
                _newPDF.Save(_reviewDoc);
                _newPDF = null;
                return true;
            }
            catch (Exception ex)
            {
                Common.Log(ex.Message);
                return false;
            }
        }
        public static bool CreatePDFToReviewV2(string sAdobePath, string sAdobeNewFilePath)
        {
            try
            {
                O2S.Components.PDF4NET.PDFDocument _ToBeCopiedPDF
                    = new O2S.Components.PDF4NET.PDFDocument();
                O2S.Components.PDF4NET.PDFDocument _newPDF
                    = new O2S.Components.PDF4NET.PDFDocument();
                O2S.Components.PDF4NET.PDFPage _pdfPage;


                _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
                _ToBeCopiedPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

                Stream _fileStream = null;

                DataSet ds = new DataSet();
                DataTable MyTable = null;
                DataRow MyRow = null;
                DataView dv = null;

                ReviewPages = 0;

                int lFileCount = 0;

                DirectoryInfo di = new DirectoryInfo(sAdobePath);
                FileInfo[] rgFiles = di.GetFiles("*.pdf*");

                using (SqlConnection cn = new SqlConnection(Database.WaldenConnect))
                {
                    cn.Open();
                    using (SqlCommand cm = cn.CreateCommand())
                    {

                        cm.CommandText = "delete from ScanFiles";
                        cm.ExecuteNonQuery();

                        string sSQL = string.Empty;
                        System.Data.SqlClient.SqlDataAdapter sSQLAdp = null;
                        sSQL = "select FileName,FileDate from ScanFiles"
                            + " where AccountID = " + Common.AccountID
                            + " order by FileDate desc";
                        using (sSQLAdp = new System.Data.SqlClient.SqlDataAdapter(sSQL, cn))
                        {
                            sSQLAdp.Fill(ds, "ScanFiles");
                            MyTable = ds.Tables[0];
                            foreach (FileInfo fi in rgFiles)
                            {
                                MyRow = MyTable.NewRow();
                                MyRow["FileName"] = fi.FullName;
                                MyRow["FileDate"] = fi.CreationTime.ToString();
                                MyTable.Rows.Add(MyRow);
                                lFileCount++;
                            }
                            string[] srcFilesNames = new string[lFileCount];
                            dv = MyTable.DefaultView;

                            dv.Sort = "FileDate";

                            for (int b = 0; b < dv.Count; b++)
                            {
                                try
                                {
                                    _fileStream = new FileStream(dv[b].Row[0].ToString(), FileMode.Open);
                                    _ToBeCopiedPDF
                                        = new O2S.Components.PDF4NET.PDFDocument(_fileStream);

                                }
                                catch (Exception ex)
                                {
                                    Common.Log(ex.Message);
                                    return false;
                                }
                                //Write document file name and page number on each page
                                for (int i = 0; i < _ToBeCopiedPDF.Pages.Count; i++)
                                {
                                    _pdfPage = _ToBeCopiedPDF.Pages[i];
                                    _newPDF.Pages.Add(_pdfPage);

                                }
                                _fileStream.Close();
                            }
                        }
                        _newPDF.Save(sAdobeNewFilePath);
                        _newPDF.Dispose();
                    }
                }
                return true;
            }
            catch (Exception er)
            {
                Common.Log(er.Message);
                return false;
            }
        }
        public static bool DeletePDFPages(string _reviewDocument, int iPageToDelete)
        {
            try
            {
                O2S.Components.PDF4NET.PDFDocument _newPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_reviewDocument);

                _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

                _newPDF.Pages.RemoveAt(iPageToDelete - 1);
                _newPDF.Save(_reviewDocument);
                return true;
            }
            catch (Exception ex)
            {
                Common.Log(ex.Message);
                return false;
            }
        }
        public static bool DeleteMultiplePDFPages(string _reviewDocument,
            int _startPage, int _deleteToPageTo)
        {
            try
            {
                O2S.Components.PDF4NET.PDFDocument _newPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_reviewDocument);

                _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

                _startPage = _startPage - 1;

                for (int i = _startPage; i < _deleteToPageTo; i++)
                {
                    _newPDF.Pages.RemoveAt(_startPage);
                }
                _newPDF.Save(_reviewDocument);
                _newPDF = null;
                return true;
            }
            catch (Exception ex)
            {
                Common.Log(ex.Message);
                return false;
            }
        }
        public static bool MergeTwoDocumentsNoDelition(string _documentToMerge,
            string _MergedDocument)
        {

            O2S.Components.PDF4NET.PDFDocument _toBeCopied1PDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFDocument _toBeCopied2PDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFDocument _mergedPDF
                = new O2S.Components.PDF4NET.PDFDocument();

            _toBeCopied1PDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
            _toBeCopied2PDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
            _mergedPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

            O2S.Components.PDF4NET.PDFPage _pdfPage;
            Stream _fileStream = null;
            Stream _fileStream2 = null;

            //Merged document may be read only Need to change attributes so it can
            //be written to
            MakeDocumentReadable(_MergedDocument);

            //Create string name with a 1 added 
            string sTempName = _MergedDocument.Replace(".pdf", "temp.pdf");

            //Copy current document to name with 1 added
            File.Copy(_MergedDocument, sTempName, true);

            //Open the New document  By opening it first
            //these pages will be placed at the top of the
            //document
            _fileStream = new FileStream(_documentToMerge, FileMode.Open);
            _toBeCopied1PDF
                = new O2S.Components.PDF4NET.PDFDocument(_fileStream);

            for (int i = 0; i < _toBeCopied1PDF.Pages.Count; i++)
            {
                _pdfPage = _toBeCopied1PDF.Pages[i];
                _mergedPDF.Pages.Add(_pdfPage);
            }

            //Adding pages to the document with the name that is in 
            //the database for that folder.  These are the pages that
            //are currently in the document

            _fileStream2 = new FileStream(sTempName, FileMode.Open);
            _toBeCopied2PDF
                = new O2S.Components.PDF4NET.PDFDocument(_fileStream2);

            //Write document file name and page number on each page
            for (int i = 0; i < _toBeCopied2PDF.Pages.Count; i++)
            {
                _pdfPage = _toBeCopied2PDF.Pages[i];
                _mergedPDF.Pages.Add(_pdfPage);
            }

            _fileStream.Close();
            _fileStream2.Close();
            //Save new document over the old document. 
            //It will be overwritten
            _mergedPDF.Save(_MergedDocument);

            //Delete temporary documents
            File.Delete(sTempName);
            //File.Delete(_documentToMerge);
            return true;
        }
        public static MemoryStream CreatePreviewFax(StringCollection _listOfPdfs)
        {
            O2S.Components.PDF4NET.PDFDocument _ToBeCopiedPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFDocument _newPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFPage _pdfPage;
            Stream _fileStream = null;

            _ToBeCopiedPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
            _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

            for (int i = 0; i < _listOfPdfs.Count; i++)
            {
                MakeDocumentReadable(_listOfPdfs[i]);
                _fileStream = new FileStream(_listOfPdfs[i], FileMode.Open);
                _ToBeCopiedPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_fileStream);

                for (int j = 0; j < _ToBeCopiedPDF.Pages.Count; j++)
                {
                    _pdfPage = _ToBeCopiedPDF.Pages[j];
                    _newPDF.Pages.Add(_pdfPage);
                }
                _fileStream.Close();
            }

            MemoryStream _newPDFStream = new MemoryStream();
            _newPDF.Save(_newPDFStream);
            
            return _newPDFStream;
        }
        public static string CombineMultiplePDFsDelete(StringCollection _listOfPdfs, string _pathNewPDF)
        {
            O2S.Components.PDF4NET.PDFDocument _ToBeCopiedPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFDocument _newPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFPage _pdfPage;
            Stream _fileStream = null;

            string _newName = "\\" + Common.GetFileNameFromDateTimeString() + ".pdf";

            _ToBeCopiedPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
            _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

            for (int i = 0; i < _listOfPdfs.Count; i++)
            {
                MakeDocumentReadable(_listOfPdfs[i]);
                _fileStream = new FileStream(_listOfPdfs[i], FileMode.Open);
                _ToBeCopiedPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_fileStream);

                for (int j = 0; j < _ToBeCopiedPDF.Pages.Count; j++)
                {
                    _pdfPage = _ToBeCopiedPDF.Pages[j];
                    _newPDF.Pages.Add(_pdfPage);
                }
                _fileStream.Close();
            }

            //Save new document over the old document. 
            //It will be overwritten
            _newPDF.Save(_pathNewPDF + _newName);

            for (int i = 0; i < _listOfPdfs.Count; i++)
            {
                File.Delete(_listOfPdfs[i]);
            }

            return _pathNewPDF + _newName;
        }
        public static string CombineMultiplePDFs(StringCollection _listOfPdfs, string _pathNewPDF)
        {
            O2S.Components.PDF4NET.PDFDocument _ToBeCopiedPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFDocument _newPDF
                = new O2S.Components.PDF4NET.PDFDocument();
            O2S.Components.PDF4NET.PDFPage _pdfPage;
            Stream _fileStream = null;

            _ToBeCopiedPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";
            _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

            for (int i = 0; i < _listOfPdfs.Count; i++)
            {
                MakeDocumentReadable(_listOfPdfs[i]);
                _fileStream = new FileStream(_listOfPdfs[i], FileMode.Open);
                _ToBeCopiedPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_fileStream);

                for (int j = 0; j < _ToBeCopiedPDF.Pages.Count; j++)
                {
                    _pdfPage = _ToBeCopiedPDF.Pages[j];
                    _newPDF.Pages.Add(_pdfPage);
                }
                _fileStream.Close();
            }

            //Save new document over the old document. 
            //It will be overwritten
            int rr = _newPDF.Pages.Count;
            _newPDF.Save(_pathNewPDF);

            return "OK";
        }
        public static bool SplitTwoPDFDocumentsV2(string _document1, string _document2,
            int _startPage, int _numberOfPages)
        {
            try
            {
                string _fileToProcess = string.Empty;
                Stream _fileStream = null;

                _fileToProcess = _document2.Replace(".pdf", "temp.pdf");

                File.Copy(_document1, _fileToProcess, true);

                _fileStream = new FileStream(_fileToProcess, FileMode.Open);

                O2S.Components.PDF4NET.PDFDocument _newPDF
                    = new O2S.Components.PDF4NET.PDFDocument(_fileStream);

                _newPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

                O2S.Components.PDF4NET.PDFDocument _firstSplitPDF
                    = new O2S.Components.PDF4NET.PDFDocument();

                _firstSplitPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

                O2S.Components.PDF4NET.PDFDocument _secondSplitPDF
                    = new O2S.Components.PDF4NET.PDFDocument();

                _secondSplitPDF.SerialNumber = "PDF4NET-AYBAM-8ARRR-B4EX2-OXGCC-KN2Q5";

                O2S.Components.PDF4NET.PDFPage _pdfPage;

                for (int i = 0; i < _startPage; i++)
                {
                    _pdfPage = _newPDF.Pages[i];
                    _firstSplitPDF.Pages.Add(_pdfPage);
                }

                for (int i = _startPage; i < _numberOfPages; i++)
                {
                    _pdfPage = _newPDF.Pages[i];
                    _secondSplitPDF.Pages.Add(_pdfPage);
                }

                _firstSplitPDF.Save(_document1);
                _secondSplitPDF.Save(_document2);

                _fileStream.Close();

                return true;
            }
            catch (Exception ex)
            {
                Common.Log(ex.Message);
                return false;
            }
        }