private void verifysendsingletomultiple(string xtemplate, DataTable dt)
        {
            addresscollection aic = new addresscollection();
            string x = null;
            x = xtemplate;
            System.Xml.XmlNode batchnode = null;
            System.Xml.XmlNode recipients = null;

            FileStream x1 = new FileStream(_sourcefilename, FileMode.Open);
            iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(x1);
            //AWESOME!!
            x1.Close();
            x1.Dispose();
            string s = "";
            string s1 = "";
            int nop = reader.NumberOfPages;
            reader.Close();
            System.Xml.XmlNode ep = null;
            System.Xml.XmlNode batch = null;
            int pages = reader.NumberOfPages;
            int i = 0;
            foreach (DataRow r in dt.Rows) {
                this.Label2.Invoke(new updatetext(updatelabel1text), new object[] { "Processing Page " + (i + 1) + " of " + dt.Rows.Count });
                i += 1;
                foreach (DataColumn c in dt.Columns) {
                    try {
                        if ((!object.ReferenceEquals(dt.Rows[1][c], DBNull.Value))) {
                            x = Strings.Replace(x, "{" + c.ColumnName + "}", (string) r[c]);
                        } else {
                            x = Strings.Replace(x, "{" + c.ColumnName + "}", "");
                        }

                    } catch {
                    }
                }
                x = Regex.Replace(x, "^\\s+$[\\r\\n]*", "", RegexOptions.Multiline);
                addressitem ai = null;

                if (parseaddresssingledoctomultiple(ref ai, ref batchnode, x, 1, nop, i, ref recipients)) {
                }
                //EVERY PAGE IS GOOD
                aic.Add(ai);
                x = xtemplate;
            }
            //Me.DataGridView2.DataSource = aic

            this.RichTextBox1.Invoke(new updatert(updaterichtext), new object[] {
                XMLDOC,
                badaddress
            });
            //Me.RichTextBox1.Invoke(New updatert(AddressOf updaterichtext), New Object() {badaddress})
            Invoke(new updatedatagrid(updatedatagridonMail), new object[] { aic });
            Invoke(new updatecomplete(updatecompleted), new object[]{});
        }
        private void verifySingleItem()
        {
            addresscollection aic = new addresscollection();
            string sourceFileName = _sourcefilename;
            FileStream x = new FileStream(sourceFileName, FileMode.Open);
            iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(x);

            //AWESOME!!
            //      x.Close()

            //x.Dispose()
            string s = "";
            string s1 = "";
            System.Xml.XmlNode ep = null;
            System.Xml.XmlNode batch = null;
            int pages = reader.NumberOfPages;
            reader.Close();
            x.Close();
            if (parseaddresssingle(ref _aiSingle, pages)) {
                //Des not catch a single first page, anytime this is true it's a new first page
                //    ep.InnerText = i + 1
                // Console.WriteLine(ai.Address1)

            }
            aic.Add(_aiSingle);

            reader.Close();
            //Me.RichTextBox1.Invoke(New updatert(AddressOf updaterichtext), New Object() {XMLDOC.OuterXml, badaddress})
            Invoke(new updatert(updaterichtext), new object[] {
                XMLDOC,
                badaddress
            });
            //Me.RichTextBox1.Invoke(New updatert(AddressOf updaterichtext), New Object() {badaddress})
            Invoke(new updatedatagrid(updatedatagridonMail), new object[] { aic });
            Invoke(new updatecomplete(updatecompleted), new object[]{});

            //rtrf(0) = rf2
            //textExtractionStrategy = New iTextSharp.text.pdf.parser.FilteredTextRenderListener(mystrat, rtrf)
            //MsgBox(iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, 1, textExtractionStrategy))
            // iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, 1, textExtractionStrategy)
        }
        public void verify()
        {
            addresscollection aic = new addresscollection();
            addressitem ai = null;
            string sourceFileName = _sourcefilename;
            FileStream x = new FileStream(sourceFileName, FileMode.Open);
            iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(x);
            //AWESOME!!
            x.Close();
            x.Dispose();
            string s = "";
            string s1 = "";
            System.Xml.XmlNode ep = null;
            System.Xml.XmlNode batch = null;
            System.Xml.XmlNode startingpage = null;
            System.Xml.XmlNode envelope = null;
            int pages = reader.NumberOfPages;
            int i;
            for (i = 0; i <= reader.NumberOfPages - 1; i++) {
                this.Label2.Invoke(new updatetext(updatelabel1text), new object[] { "Processing Page " + Convert.ToString(i + 1)  + " of " + pages });
                DataRow dr = _dtt.Rows[0];
                System.util.RectangleJ rect1 = new System.util.RectangleJ(Convert.ToInt32( dr["x"]), Convert.ToInt32( dr["y"]), Convert.ToInt32( dr["width"]), Convert.ToInt32( dr["height"]));
                iTextSharp.text.pdf.parser.RegionTextRenderFilter rf = new iTextSharp.text.pdf.parser.RegionTextRenderFilter(rect1);
                iTextSharp.text.pdf.parser.LocationTextExtractionStrategy mystrat = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();
                iTextSharp.text.pdf.parser.RegionTextRenderFilter[] rtrf = new iTextSharp.text.pdf.parser.RegionTextRenderFilter[2];
                rtrf[0] = rf;
                //Dim rect2 As New System.util.RectangleJ(0, 700, 800, 140)
                //Dim rf2 As New iTextSharp.text.pdf.parser.RegionTextRenderFilter(rect2)
                iTextSharp.text.pdf.parser.FilteredTextRenderListener textExtractionStrategy = new iTextSharp.text.pdf.parser.FilteredTextRenderListener(mystrat, rtrf);

                DataRow dr1 = _dtt.Rows[1];
                System.util.RectangleJ rect2 = new System.util.RectangleJ(Convert.ToInt32( dr1["x"]), Convert.ToInt32( dr1["y"]), Convert.ToInt32( dr1["width"]), Convert.ToInt32( dr1["height"]));
                iTextSharp.text.pdf.parser.RegionTextRenderFilter rf1 = new iTextSharp.text.pdf.parser.RegionTextRenderFilter(rect2);
                iTextSharp.text.pdf.parser.LocationTextExtractionStrategy mystrat1 = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();
                iTextSharp.text.pdf.parser.RegionTextRenderFilter[] rtrf1 = new iTextSharp.text.pdf.parser.RegionTextRenderFilter[2];
                rtrf1[0] = rf1;
                //Dim rect2 As New System.util.RectangleJ(0, 700, 800, 140)
                //Dim rf2 As New iTextSharp.text.pdf.parser.RegionTextRenderFilter(rect2)
                iTextSharp.text.pdf.parser.FilteredTextRenderListener textExtractionStrategy1 = new iTextSharp.text.pdf.parser.FilteredTextRenderListener(mystrat1, rtrf1);

                s = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, i + 1, textExtractionStrategy);

                if (!string.IsNullOrEmpty(s)) {
                    s1 = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, i + 1, textExtractionStrategy1);

                    if (parseaddress(s, s1, ref batch, i + 1, ref ep, ref envelope, ref startingpage, ref ai)) {
                        //Des not catch a single first page, anytime this is true it's a new first page
                        //    ep.InnerText = i + 1
                        // Console.WriteLine(ai.Address1)
                        aic.Add(ai);
                    }

                }

                if (i == reader.NumberOfPages - 1 & (ep != null)) {
                    ep.InnerText = Convert.ToString(i + 1);
                }

                if (i == reader.NumberOfPages - 1 & (ai != null)) {
                    ai.endpage = Convert.ToInt32( i + 1);
                }
                // CurrentPage = CurrentPage + 1
            }
            reader.Close();
            //Me.RichTextBox1.Invoke(New updatert(AddressOf updaterichtext), New Object() {XMLDOC.OuterXml, badaddress})
            this.RichTextBox1.Invoke(new updatert(updaterichtext), new object[] {
                XMLDOC,
                badaddress
            });
            //Me.RichTextBox1.Invoke(New updatert(AddressOf updaterichtext), New Object() {badaddress})
            Invoke(new updatedatagrid(updatedatagridonMail), new object[] { aic });
            Invoke(new updatecomplete(updatecompleted), new object[]{});

            //rtrf(0) = rf2
            //textExtractionStrategy = New iTextSharp.text.pdf.parser.FilteredTextRenderListener(mystrat, rtrf)
            //MsgBox(iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, 1, textExtractionStrategy))
            // iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, 1, textExtractionStrategy)
        }