fixes a bug in such Pdf generation
This commit is contained in:
parent
9b342040ff
commit
f30d493f6e
1 changed files with 23 additions and 25 deletions
|
|
@ -14,7 +14,19 @@ namespace Yavsc.Helpers
|
||||||
public class TeXString : HtmlString
|
public class TeXString : HtmlString
|
||||||
{
|
{
|
||||||
|
|
||||||
public class Replacement
|
public TeXString(TeXString teXString): base(teXString.ToString())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeXString(string str) : base(str)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public class Replacement
|
||||||
{
|
{
|
||||||
string target;
|
string target;
|
||||||
string replacement;
|
string replacement;
|
||||||
|
|
@ -28,8 +40,9 @@ namespace Yavsc.Helpers
|
||||||
return source.Replace(target, replacement);
|
return source.Replace(target, replacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static class TeXHelpers
|
||||||
public readonly static Replacement[] SpecialCharsRendering =
|
{
|
||||||
|
public static readonly Replacement[] SpecialCharsRendering =
|
||||||
{
|
{
|
||||||
new Replacement("<","\\textless"),
|
new Replacement("<","\\textless"),
|
||||||
new Replacement(">","\\textgreater"),
|
new Replacement(">","\\textgreater"),
|
||||||
|
|
@ -54,26 +67,16 @@ namespace Yavsc.Helpers
|
||||||
new Replacement("†","\\dag"),
|
new Replacement("†","\\dag"),
|
||||||
new Replacement("–","\\textendash")
|
new Replacement("–","\\textendash")
|
||||||
};
|
};
|
||||||
|
|
||||||
public TeXString(string str) : base(TR(str))
|
public static TeXString ToTeX(this string source)
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
private static string TR(string source)
|
|
||||||
{
|
{
|
||||||
string result=source;
|
string result=source;
|
||||||
foreach (var r in SpecialCharsRendering)
|
foreach (var r in SpecialCharsRendering)
|
||||||
{
|
{
|
||||||
result = r.Execute(result);
|
result = r.Execute(result);
|
||||||
}
|
}
|
||||||
return result;
|
return new TeXString(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TeXHelpers
|
|
||||||
{
|
|
||||||
public static string NewLinesWith(this string target, string separator)
|
public static string NewLinesWith(this string target, string separator)
|
||||||
{
|
{
|
||||||
var items = target.Split(new char[] { '\n' }).Where(
|
var items = target.Split(new char[] { '\n' }).Where(
|
||||||
|
|
@ -85,19 +88,14 @@ namespace Yavsc.Helpers
|
||||||
public static TeXString ToTeX(this string target, string lineSeparator = "\n\\\\")
|
public static TeXString ToTeX(this string target, string lineSeparator = "\n\\\\")
|
||||||
{
|
{
|
||||||
if (target == null) return null;
|
if (target == null) return null;
|
||||||
return new TeXString(target.NewLinesWith(lineSeparator));
|
return new TeXString( target.ToTeX().ToString().NewLinesWith(lineSeparator) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HtmlString SplitAddressToTeX (this string target)
|
public static TeXString SplitAddressToTeX (this string target)
|
||||||
{
|
{
|
||||||
var alines = target.Split(',');
|
var alines = target.Split(',');
|
||||||
var texlines = alines.Select(l=>new TeXString(l));
|
var texlines = alines.Select(l=>l.ToTeX().ToString());
|
||||||
StringBuilder sb = new StringBuilder();
|
return new TeXString(string.Join("\\\\\n",texlines));
|
||||||
foreach (var l in texlines)
|
|
||||||
{
|
|
||||||
sb.AppendFormat("{0}\\\\\n",l.ToString());
|
|
||||||
}
|
|
||||||
return new HtmlString(sb.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool GenerateEstimatePdf(this PdfGenerationViewModel Model)
|
public static bool GenerateEstimatePdf(this PdfGenerationViewModel Model)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue