Telerik Forums
Telerik Document Processing Forum
1 answer
11 views
I have a DOCX Template that has multiple merge fields defined. One of those fields is for an image. How can I get MailMerge to insert images into a merge field.
Dess | Tech Support Engineer, Principal
Telerik team
 answered on 23 Feb 2024
0 answers
16 views
Hello! I'm currently attempting to transform an HTML body into a PDF using HtmlFormatProvider, RadFlowDocument, and PdfFormatProvider.

Everything functions good when generating a PDF with standard characters. However, when incorporating characters such as "ćšđž," these specific characters seem to be missing.

Could you kindly provide guidance on resolving this issue?
Sanja Tolo
Top achievements
Rank 1
Iron
Iron
 asked on 09 Feb 2024
0 answers
21 views

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.

Patrick
Top achievements
Rank 1
 updated question on 06 Feb 2024
1 answer
14 views

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

 

 

Dess | Tech Support Engineer, Principal
Telerik team
 answered on 22 Dec 2023
1 answer
19 views
Please help with adding some text into run with substring numbers (chemical formula)
How to do this?
Yoan
Telerik team
 answered on 18 Dec 2023
1 answer
29 views

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);
}

Yoan
Telerik team
 answered on 18 Dec 2023
1 answer
35 views

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

Martin
Telerik team
 answered on 03 Oct 2023
1 answer
82 views

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);
This code works . The output looks like this:
<body><p style="margin-bottom: 0px;"><span style="font-size: 13.333333333333334px;">Dampf- und Gassperre aus Fl&uuml;ssigkunststoff f&uuml;r D&auml;mmung von K&auml;lteleitungen. Flexible, schwerentflammbare und dampfbremsende Beschichtung auf Wasserbasis. Auch geeignet zum Schutz von l&ouml;sungsmittelempfindlichen Isolierstoffenbei K&auml;lte-Isolierungen im Innen- und Aussenbereich.</span></p></body>
How can I remove or replace the style-attribute with the font-size in the span?
Anna
Telerik team
 answered on 29 Sep 2023
1 answer
39 views

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";	

}

Vladislav
Telerik team
 answered on 17 Jul 2023
1 answer
53 views
I want to learn more about Word processing and how to create tables in the Word document.
Unfortunately I only ever see c# code.
Can someone show me an example for VB.NET ?
A simple table with cell contents..
Yoan
Telerik team
 answered on 13 Jul 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?