private void ParseTextLines(string print) { string[] lines = print.Split('\n'); string fontSizeConstant = "%FONT-SIZE%"; int numberStart = fontSizeConstant.Length + 2; this.linesInfo = new List <TextLineData>(lines.Length); //Pomijam pierwszy wiersz <root>.... oraz ostatni %KONIEC-STRONY% gdyż sam wstawiam koniec-strony for (int i = 0; i < lines.Length - 1; i++) { string line = lines[i]; this.linesInfo.Add(new TextLineData() { Size = line.TrimStart().StartsWith(fontSizeConstant) ? System.Convert.ToDecimal(line.Substring(numberStart, line.IndexOf("pt_on") - numberStart) , CultureInfo.InvariantCulture) : this.DefaultFontSize, RawText = line, TrimmedText = PagingLogic.ReplaceSpecialCodes(line).Trim() }); } }
public static string Generate(string xml, Stream output, string driverConfigXml = null) { StreamWriter w = new StreamWriter(output, Encoding.UTF8); MakoPrintText mp = new MakoPrintText(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.PreserveWhitespace = true; xmlDocument.LoadXml(xml); string result = mp.Convert(xmlDocument); #region Extract paging element if (driverConfigXml != null) { XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(driverConfigXml); XmlNodeList list = xdoc.DocumentElement.GetElementsByTagName("paging"); if (list.Count > 0 && list[0].NodeType == XmlNodeType.Element) { XmlElement pagingElement = (XmlElement)list[0]; PagingLogic pagingLogic = new PagingLogic(pagingElement, mp); result = pagingLogic.TryApplyPaging(result); } } #endregion foreach (XmlNode child in xmlDocument.DocumentElement.ChildNodes) { xmlDocument.DocumentElement.RemoveChild(child); } w.Write(xmlDocument.DocumentElement.OuterXml); w.Write("@@@@"); w.Write(result); w.Flush(); return(result); }