private void PrintDocumentFromTemplate(String Template, Int64 documentId, String connectionstring) { XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(Template); XmlNode document = xmldoc.SelectSingleNode(@"document"); XmlNode data = xmldoc.SelectSingleNode(@"document/data"); XmlNode header = xmldoc.SelectSingleNode(@"document/header"); XmlNode body = xmldoc.SelectSingleNode(@"document/body"); XmlNode footer = xmldoc.SelectSingleNode(@"document/footer"); job.cols = Convert.ToInt32(document.Attributes["width"].Value); job.rows = Convert.ToInt32(document.Attributes["height"].Value); LoadData(data, documentId, connectionstring); //ADDED TO ENABLE OR DIABLE AUTO FEED if (document.Attributes["auto-feed-paper"].Value == "1") { printer.autoFeedToTearOff(true); } //printer.autoFeedToTearOff(true); //I dont understand what the below method is suppose to do but is causes a "V" to print as the 1st Char of the document when printing to epson dot matrix printers if (document.Attributes["auto-cut-paper"].Value == "1") { printer.autoCutToTearOff(true); } //iet rerig seker of die goed ooit werk nie printer.startJob(port, job); //printer.executeCommand("CMD_PAGE_LENGTH_INCHES", "11"); //printer.executeCommand("CMD_PAGE_LENGTH_LINES", "57"); Int32 maxlines = Convert.ToInt32(body.Attributes["pagemax"].Value); XmlNodeList items = body.SelectNodes("item"); int numpages = (int)Math.Ceiling(datacollection.Tables[items[0].Attributes["dataset"].Value].Rows.Count / (double)maxlines); for (int i = 0; i < numpages; i++) { //printer.executeCommand("CMD_UTIL_NLQ_SELECTION"); //printer.executeCommand("CMD_PICA_PITCH"); printer.executeCommand("CMD_PAGE_LENGTH_INCHES", document.Attributes["height-inches"].Value); PrintSection(header, i, numpages); //printer.executeCommand("CMD_ELITE_PITCH"); PrintItemSection(body, i, numpages, maxlines); PrintSection(footer, i, numpages); //printer.executeCommand("CMD_PICA_PITCH"); //printer.executeCommand("CMD_MOVE_LINE"); if (i < (numpages - 1)) { printer.newPage(); } } //datacollection.Tables[items[0].Attributes["dataset"].Value].Rows.Count }