Numeric (Width) expression issues in EvalScript for locale French, Swedish and Portuguese
Summary
After localising our application, we're getting exceptions when generating a PDF or RTF in the following locales:
- French (fr-FR)
- Swedish (pt-PT)
- Portuguese (sv-SE)
Notes
Windows Forms application compiled against .NET Framework v4.7.2 any-cpu. The application is forced into chosen specific locale during startup before running the UI using the following code:
var culture = CultureInfo.GetCultureInfo(selectedLanguage.Code);
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;
If I am able to find the extra time, I'll reference a debug build of MigraDocXml + EvalScript and try to find out exactly what is tripping it up.
Template
By painful elimination, I've narrowed it down to any expression using ContentWidth
, here assigned to the variable contentWidth
, and using <p>{contentWidth}</p>
prints the text 180mm
.
<Var contentWidth="Section.PageSetup.ContentWidth"
contentHeight="Section.PageSetup.ContentHeight"
topMargin="Section.PageSetup.TopMargin"
bottomMargin="Section.PageSetup.BottomMargin"
leftMargin="Section.PageSetup.LeftMargin"
rightMargin="Section.PageSetup.RightMargin"/>
<Style Target="Table" Name="Tabulated">
<Setters/>
</Style>
<Style Target="Column" Name="TabulatedC0">
<Setters Width="65mm"/>
</Style>
<Style Target="Column" Name="TabulatedC1">
<Setters Width="55mm" Format.Alignment="Right"/>
</Style>
<Header IsPrimary="true">
<Table LeftPadding="0" RightPadding="0" TopPadding="0" BottomPadding="0">
<Column Width="{contentWidth * 0.50}"/> <!-- EXCEPTION HERE -->
<Column Width="{contentWidth * 0.25}"/>
<Column Width="{contentWidth * 0.25}" Format.Alignment="Right"/>
<Row Height="15mm">
...
Exception
EvalScript.SyntaxException: Unrecognised numeric literal at: Document/Section/Insert/Header/Table/Column ---> EvalScript.SyntaxException: Unrecognised numeric literal
at EvalScript.Interpreting.Stage2.NumericLiteralIdentifier.Run(Interpreter interpreter, List`1 input)
at EvalScript.Interpreting.Interpreter.Run(String code)
at EvalScript.Runner.Run(String code, Func`2 variableLookup)
at MigraDocXML.PdfXmlReader.InterpretString(String text, DOMElement caller, Boolean textCleanup)
at MigraDocXML.PdfXmlReader.InterpretString(String text, DOMElement caller)
at MigraDocXML.PdfXmlReader.SetPropertiesFromAttributes(XmlElement xml, DOMElement dom)
at MigraDocXML.PdfXmlReader.ReadChildElements(XmlElement xml, DOMElement dom)
--- End of inner exception stack trace ---
at MigraDocXML.PdfXmlReader.Run(Object model)
at NetTools.Render.RtfRendering.RtfRenderer.RenderRtf(String layoutFile, JToken content) in ###.Render\RtfRendering\RtfRenderer.cs:line 51
at NetTools.Render.RtfRendering.RtfRenderer.RenderBatchReport(JToken report) in ###.Render\RtfRendering\RtfRenderer.cs:line 35
at NetTools.Model.Report.Report.RenderAsRtf(JToken report, String username) in ###.Model\Report\Report.cs:line 77
at NetTools.Model.Model.RenderReportAsRtf(JToken content, String username) in ###.Model\Model.cs:line 440
at NetTools.Report.ReportView.RenderReport() in ###\Report\ReportView.cs:line 45