I created a test docx with the following text in a justified format:
"This is a brand-new document with justified text. Putting extra text into the paragraph in order to highlight the specific justified format text. This is simply test text in order to demonstrate the issue that I am having when I attempt to use the Telerik rad document find all."
I then upload the document into Session and save the file binary by converting the File.InputStream to Base64Stream.
I then create a find text of "This is simply test text".
The resulting IReadOnlyCollection<FindResult> of editor.FindAll(txtFind, false, true); contains one result with three runs.
"highlight the specific justified format text. This is simply"
"test"
"text in order to demonstrate the issue that I am having when I attempt to use the Telerik rad document find all.
I had assumed that setting match whole word would return a better result, but it does not.
I think I do not understand the concept of "runs". There is no other formatting other than justification.
I expected either the sentence that the text resides in to return OR the entire paragraph. Not three incomplete sentences, one just including one word.
Hi,
I would like to create a new style with the All Caps Font Effect enabled in my Word document (refer to the attached image).
How can I do this programmatically?
I was expecting to be able to do it like this, but I cannot find any property to set the All Caps.
var document = new RadFlowDocument();
var style = new Style("ALL_CAPS", StyleType.Paragraph)
{
Name = "ALL_CAPS",
BasedOnStyleId = BuiltInStyleNames.NormalStyleId
};
style.CharacterProperties.AllCaps.LocalValue = true;
document.StyleRepository.Add(style);
Thank you
I'm trying to convert a word document to PDF and the images and shapes it contains, along with their text, do not make it into the PDF. Are these not yet supported?
The attached zip contains the original document and the result of the conversion.
The conversion code is pretty straightforward, basically just
DocxFormatProvider docxProvider = new DocxFormatProvider();
var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
RadFlowDocument document = null;
using (Stream input = File.OpenRead("WordDocWithGraphics.docx"))
{
document = docxProvider.Import(input);
}
using (Stream output = File.OpenWrite(("WordDocWithGraphics.pdf"))
{
pdfProvider.Export(document, output);
}
Hi,
I get HTML in my code and I have the image byte in another file. I want to combine it to export my HTML to PDF with images. This is what I do, and it only works with a single image, on the second iteration I got an error in importSettings.LoadImageFromUri (Method = <Internal Error evaluating expression>). What can I do to add multiple images in the importSettings? I don't see an example in the documentation.
foreach (var img in imageList)
{
EventHandler<LoadImageFromUriEventArgs> loadImageFromUri = (s, e) =>
{
byte[] data = img.ContentBytes;
e.SetImageInfo(data, "jpg");
};
importSettings.LoadImageFromUri += loadImageFromUri;
}
Thanks
We store some texts in rtf-format in our database. Now I have to convert them to html.
This is an expample of the rtf-text:
{\rtf1\ansi\ansicpg1252\deff0\deflang2055{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\fs20 Dampf- und Gassperre aus Fl\'fcssigkunststoff f\'fcr D\'e4mmung von K\'e4lteleitungen. Flexible, schwerentflammbare und dampfbremsende Beschichtung auf Wasserbasis. Auch geeignet zum Schutz von l\'f6sungsmittelempfindlichen Isolierstoffenbei K\'e4lte-Isolierungen im Innen- und Aussenbereich.\f1\fs17\par
}
To convert it to html I use the following code:
Telerik.Windows.Documents.Flow.FormatProviders.Rtf.RtfFormatProvider rtfProv = new();
Telerik.Windows.Documents.Flow.Model.RadFlowDocument rtfDoc = rtfProv.Import(rtfInput);
Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlExportSettings expSettings = new()
{
DocumentExportLevel = Telerik.Windows.Documents.Flow.FormatProviders.Html.DocumentExportLevel.Fragment,
StylesExportMode = Telerik.Windows.Documents.Flow.FormatProviders.Html.StylesExportMode.None,
};
Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider htmlProv = new()
{
ExportSettings = expSettings
};
string ret = htmlProv.Export(rtfDoc);
return new HtmlString(ret);
<body><p style="margin-bottom: 0px;"><span style="font-size: 13.333333333333334px;">Dampf- und Gassperre aus Flüssigkunststoff für Dämmung von Kälteleitungen. Flexible, schwerentflammbare und dampfbremsende Beschichtung auf Wasserbasis. Auch geeignet zum Schutz von lösungsmittelempfindlichen Isolierstoffenbei Kälte-Isolierungen im Innen- und Aussenbereich.</span></p></body>
We have a scenario where the client is wanting a combobox in a generated Word document to have the color of the combobox change depending on the option selected (these combo boxes are repeated many times in the document so the colour change is important to the client.
Screenshot shows the Combobox in use. Below is the snippet of my code. Is there a way to do what I am after?
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
// In my source (an html document that was converted to a Word Document higher in the code) "#ddlApplies" is where I need to place a ComboBox
// It is in a table cell.
ReadOnlyCollection<FindResult> findResults = editor.FindAll("#ddlApplies", matchCase: false, matchWholeWord: false);
foreach (var item in findResults)
{
string foundVal = item.Runs[0].Text.Replace("#", "");
// The full run name consists of "#ddl|Identifier". In Furture dev we will use the Identifier (which is put in as the alias) to identify which control this is so we can read in the document and update other datasets
//var ddlContentControl = editor.InsertStructuredDocumentTag(SdtType.ComboBox);
ComboBoxProperties properties = new ComboBoxProperties();
// Complies --- Green
// Does not Comply --- Red
// Minor Variation --- Orange
// N/A -- Grey
properties.Items.Add(new ListItem() { DisplayText = "Complies", Value = "Complies" });
properties.Items.Add(new ListItem() { DisplayText = "Does not Comply", Value = "Does not Comply" });
properties.Items.Add(new ListItem() { DisplayText = "Minor Variation", Value = "Minor Variation" });
properties.Items.Add(new ListItem() { DisplayText = "N/A", Value = "N/A" });
// Setting the alias with the identifier.
properties.Alias = foundVal.Split("|")[1];
properties.Lock = Lock.SdtLocked;
properties.Placeholder = new Placeholder() {
PlaceholderText = "Select",
ShowPlaceholder = true
};
properties.OutlineAppearance = OutlineAppearance.BoundingBoxes;
//setting the properties
properties.RunProperties.CopyPropertiesFrom(item.Runs[0].Properties);
/***
Here is where I think I need to set things. But not sure how. Client wants each option to have a different colour. They would prefer the whole cell to change, but happy if I can just get the ComboBox to change.
***/
//inserting the Tag and setting the default value
editor.MoveToInlineStart(item.Runs[0]);
editor.InsertStructuredDocumentTag(properties, item.Runs[0], item.Runs[0]);
item.Runs[0].Text = "Select";
}