string cultureName = Thread.CurrentThread.CurrentCulture.Name;
CultureInfo cultureInfo= new CultureInfo(cultureName);
if (cultureInfo.NumberFormat.NumberDecimalSeparator != ".")
{
cultureInfo.NumberFormat.NumberDecimalSeparator = ".";
Thread.CurrentThread.CurrentCulture = cultureInfo;
}
WordsProcessing: Invalid font size when exporting to pdf.
Workaround:
var runs = document.EnumerateChildrenOfType<Run>();We are using the Telerik Xamarin UI components, which were released on 18th March 2020, for one of our micro-services hosted in Azure cloud, to convert rtf text to raw text. Currently we have Linux containers in Azure. The code which we are using is as follows -
var rtfFormatProvider = new RtfFormatProvider();
var txtFormatProvider = new TxtFormatProvider();
RadFlowDocument doc = null;
doc = rtfFormatProvider.Import(<<Base64_Inputstring>>.DecodeFromBase64String());
string result = txtFormatProvider.Export(doc);
However, we observed that the output of the above code is different when run on Windows platform as compared to when run on Linux platform. For Linux, the CR characters are not included in the raw text. We would like to see the same output for Linux as what we get for Windows, that is raw text with the CR characters. Is this something which can be fixed? Can you suggest a work-around for this issue?
I am attaching a sample input along with this mail, as well as the Windows output and the Linux output, for your reference.
Thanks,
Deepa
This results in a missing paragraph. For example, having a table with three cells and Page field in the footer of a document and exporting it to PDF, will not export the last paragraph.
As a workaround add new run after the last field character in the cell's table before exporting the document to PDF.
BlockCollection footerContent = this.document.Sections.First().Footers.Default.Blocks;
Table footerTable = footerContent.First() as Table;
var cells = footerTable.Rows.Last().Cells.Where(x => x.EnumerateChildrenOfType<FieldCharacter>().Any());
foreach (var cell in cells)
{
cell.Blocks.AddParagraph().Inlines.AddRun();
}
When nested div elements are imported the WordsProcessing library creates separate paragraph elements for each div. However, if the outer div doesn't contain any inline children preceding the inner div element, the first created paragraph will be removed and only the second paragraph will be left. This leads to losing any style properties of the outer div.
Example:
<div style="margin-top: 50px;">
<div>Text</div>
</div>
string html = File.ReadAllText("Source.html");
string newHtml = html.Replace("<br>", "[br]");
File.WriteAllText("NewSource.html", newHtml);
using (Stream stream = File.OpenRead("NewSource.html"))
{
HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider();
flowDocument = htmlFormatProvider.Import(stream);
TxtFormatProvider txtFormatProvider = new TxtFormatProvider();
string text = txtFormatProvider.Export(flowDocument);
string newText = text.Replace("[br]", "\r\n");
}