i have doubt on radrichtextbox and those property. am trying to do from radrichtextbox export to PDF files with image also. but i couldnot access all property in viewmodel class.can you tell me how to access and how to dynamic load all control in view model?
Example
view model class am writing one method. in this method am trying to add paragraph,section and ect.. but it is not working.
RadDocument rad = new RadDocument();
RadRichTextBox richtextbox=new RadRichTextBox();
richtextbox.Document.Section =
"10,10,10,10";
Button button = new Button();
button.Content =
"Click Me";
button.Click += OnButtonClick;
richtextbox.ChildrenOfType.Add(textBox);
24 Answers, 1 is accepted
Please find attached a demo, illustrating how you can create a document in code-behind. It also shows how you can export the document to PDF.
The InlineUIContainers, however, are not exported and the button, which you can see and click if you load the document in RadRichTextBox, will not be exported.
There should be no problem for you to implement that in your ViewModel class.
Let us know if you need further assistance.
Iva
the Telerik team
Thanks for giving good solution. how do i add image with out UIContainer. as you told that if we add UIContainer using image we cannot export data to PDF.then is there any other solution to export PDF? .i have to align some data using radrichtextbox or rad document.totally i need 4 cells(Column) and many rows.those value dynamically i have to take all data from my database table. example left hand side image.. is there any solution. please help me.. i could not find solution.finally i have export all data to PDF same format(design). Thanks in Advance.
Here below i mention example of my report.
Report Title with Logo
LastName : Vijayan
FirstName : John
_________________________ Here I want Image.10 * 10 size.
Age : 25
___________
Biography
some textsome textsome textsome textsome textsome text
some textsome textsome textsome textsome textsome text
some textsome textsome textsome textsome textsome text
If you use ImageInline, the picture will also be exported using the format provider. I have modified the previous demo to include a picture. The picture is included in the project, but it can be taken from a database, as long as you can provide a Stream that contains it.
Note, that as of now we only support inline images, that is you cannot make the text flow on the sides of the picture. However you can use tables to achieve your scenario.
All the best,
the Telerik team
Thanks for your quick response..
Sorry for disturbing again. i was created MSWord docx and i created a print template doc. example am i given below. first load all xml data to one collection then am importing all data to word to raddocument. then in this document am finding like this "<text>". then i have replaced to orinigal value. but i could not replace raddocument? ca u tell me how to do this situation? thanks in advance.
This sample of ms word content.
Player Card Profile
Profile |
|
||||
First Name |
<FirstName> <LastName> <MIName> |
Status |
<status> |
|
am writing one method like this.
private string GetActualValue(string originalValue, List<player> Players)
{
string myResult = originalValue;
if (originalValue.Substring(0, 1) == "<" && originalValue.Substring(originalValue.Length - 1, 1) == ">")
{
var result = from myPlayers in Players
where myPlayers.Title.Equals (originalValue.Substring (1,originalValue.Length-2))
select myPlayers;
if (result.ToList ().Count > 0 )
{
player myPlayer = (player)result.ToList()[0];
myResult = myPlayer.Name.ToString();
}
}
return myResult;
}
public
RadDocument ImportWordDoc()
{
LoadXML();
using (Stream stream = Application.GetResourceStream(GetResourceUri("NEW.docx")).Stream)
{
Document.LayoutMode =
DocumentLayoutMode.Flow;
Document =
new DocxFormatProvider().Import(stream);
}
foreach (Inline varInline in Document.EnumerateChildrenOfType<Inline>())
{
if (varInline.GetType().ToString().Equals("Telerik.Windows.Documents.Model.Span"))
{
((
Span)varInline).Text = GetActualValue(((Span)varInline).Text, Players);
//Span mySpan = new Span(GetActualValue(((Span)varInline).Text, Players));
// Document.Children.AddAfter(varInline, mySpan);
//bool isRemoved = Document.Children.Remove(varInline);
}
}
Document;
}
You can replace the document just by invoking:
this
.radRichTextBox.Document = Document;
However, it seems to me that your scenario is practically mail merge. This feature is on our to-do list for next year, but what you can do currently is to use the newly introduced Find functionality as shown in the demo in this forum thread.
Basically, you perform a search for a string and then, you can do as you please with the results. The method in the demo selects all occurrences of the word.
private
void
buttonFind_Click(
object
sender, RoutedEventArgs e)
{
this
.radRichTextBox.Document.Selection.Clear();
DocumentTextSearch search =
new
DocumentTextSearch(
this
.radRichTextBox.Document);
foreach
(var textRange
in
search.FindAll(
this
.textBox.Text))
{
this
.radRichTextBox.Document.Selection.AddSelectionStart(textRange.StartPosition);
this
.radRichTextBox.Document.Selection.AddSelectionEnd(textRange.EndPosition);
}
}
If you add
this
.radRichTextBox.Insert(
sometext);
Kind regards,
Iva
the Telerik team
Thanks. is there any possiblities connecting with out WCF using telerik report?. we are using MAC OS . it is not support WCF on mac machine. is there any other solution?. thanks in advance.
Thanks
Vijayan
Please, ask Telerik Reporting questions in the Telerik Reporting Forum. I am sure the Reporting guys will help you out. Just describe your problem in detail, i.e. what services you use, what technology (SL, WPF, etc) and what the exact problem is and they will help.
Kind regards,
Vassil
the Telerik team
I am using telerik radrichtextbox in that rad document. rad document is readonly mode and spellcheck=false.
am dynamically attaching all the content and sections to rad document. i can see my result. but while am drag or selecting inside rad document that time application crashed. but am using readonly mode. i dont know why happening like this.here i mention below sample code .
<
telerik:RadRichTextBox x:Name="print" IsReadOnly="True" IsSpellCheckingEnabled="False" />
<telerikControls:RadButton x:Name="ExportPDF" Content="ExportPDF" Width="80" Height="30" Click="ExportPDF_Click" VerticalAlignment="Bottom">
</telerikControls:RadButton>
one more doubt. am using rad button. i need to show in this button bottom of document.how can i find how many rad document and how can i set radbutton bottom ? am doing dynamically so i dont know how many rad document will come.
Thanks in Advance
What exception are you getting? If you open a support ticket and send over a sample project, we may be able to help you further.
Just to be on the safe side, you can view only one RadDocument in a RadRichTextBox. The sample project involved only one RadRichTextBox and one RadDocument. No matter how many sections, paragraphs, spans, etc. you add, the controls that come after the rich text box will appear properly.
If you, however, have more than one RadDocuments which you want to show in different RadRichTextBox-es, you would have to implement some custom logic of yours. One approach would be to put RadRichTextBox in a DataTemplate for some ItemsControl, e.g. a ListBox, and then set the DataContext and ItemsSource of the ListBox, as shown in the demo in this forum thread (the post from October 6th).
Another option would be to add them to the logical tree of some control, which is already created like this:
foreach
(RadDocument doc
in
documents)
{
RadRichTextBox rrtb =
new
RadRichTextBox();
rrtb.Document = doc;
layoutRoot.Children.Add(rrtb);
}
Iva
the Telerik team
Hi,
How to set the MaxLength property of the input area of the combobox? i had tried in this following example
http://www.telerik.com/help/silverlight/radcombobox-howto-set-max-length-input-area.html
i created class name as "EditableRadCombo" one project files. after that i access in this project in my Xaml page like this..
Create namespace for that project
xmlns
:Editable="clr-namespace:eAnalyze.Common"
after that am calling
<telerik:RadComboBox x:Name="EventType" Grid.Row="3" Grid.Column="1" Width="345" Height="22" SelectedIndex="0" Text="{Binding EventType}" VerticalAlignment="Center"
SelectedValue="{Binding EventType,Mode=TwoWay}" DisplayMemberPath="EventTypeName" SelectedValuePath="EventTypeID" IsTextSearchEnabled="False"
IsEditable="True" TabIndex="4" LostFocus="EventTypeLostFocus" SelectionChanged="EventType_SelectionChanged" Editable:EditableComboxMaxlengthProperty.MaxLength="10">
</telerik:RadComboBox>
if i build application got one error.
that is No maxlegth property avaiable.
Thanks
Vijayan P
The property should be set like this:
<
telerik:RadComboBox
IsEditable
=
"True"
Editable:EditableRadCombo.MaxLength
=
"10"
...>
I've attached a simple example to demonstrate the approach.
Greetings,
Yana
the Telerik team
I have opened a docx document in RadRichtextbox and looking for a way to add another document on top of this current document.
Is there a way to dynamically append one document to another opened document. Both documents are docx type.
Thanks
We are sorry for the delay, but we were busy with the new Q1 release.
You can add second document in the beginning of the existing document by creating document fragment, as follows:
private
void
buttonLoadSecondDocument_Click(
object
sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog =
new
OpenFileDialog();
if
(openFileDialog.ShowDialog() ==
true
)
{
using
(Stream stream = openFileDialog.File.OpenRead())
{
RadDocument document2 =
new
DocxFormatProvider().Import(stream);
document2.Selection.SelectAll();
this
.radRichTextBox.Document.InsertFragment(document2.Selection.CopySelectedDocumentElements());
}
}
}
Don't hesitate to contact us if you have other questions.
Greetings,Boby
the Telerik team
RadDocument docment = new PdfFormatProvider().Import(stream);
On Telerik demo site of RadRichTextEditor it is stated "Support for import/export in .docx, .html, .pdf, .xaml and .txt formats".
I am trying to import pdf document.
Thanks,
hey you have to add this two dll.
using
Telerik.Windows.Documents.FormatProviders.OpenXml.Docx;
using
Telerik.Windows.Documents.FormatProviders.Pdf;
this is method return document which contain imported docx .. just you pass local path of ms word file then it will return.
private RadDocument GetAllElementFromWord(string localPath)
{
RadDocument CommonDocument =
new RadDocument();
using (Stream stream = Application.GetResourceStream(GetResourceUri(localPath)).Stream)
{
CommonDocument.LayoutMode = DocumentLayoutMode.Flow;
CommonDocument =
new DocxFormatProvider().Import(stream);
}
return CommonDocument;
}
this method check whether correct word document file or not and return resource file. before run application make sure whether that ms word file is resource or not. if you want resource file right click ms word file property make resource file..
private
Uri GetResourceUri(string resource)
{
AssemblyName assemblyName = new AssemblyName(this.GetType().Assembly.FullName);
string resourcePath = "/" + assemblyName.Name + ";component/" + resource;
Uri resourceUri =
new Uri(resourcePath, UriKind.Relative);
return resourceUri;
}
if you have doubt on this please let me know . my mail id is vijayan.perumalsamy@marlabs.com.
Thanks
Vijayan
Thank you for taking part in this discussion. However, I think that Matt has something else in mind.
@Matt: PDF import is currently not supported. This is indeed not very clear in the article about data providers where the focus is on data binding. However, the fact that only PDF export is available is specifically accented in this article about import and export. We will make sure to update the other article, so that no more misunderstandings occur.
PDF import is on our to-do list, but has not been scheduled yet and will not be implemented for Q2.
Iva
the Telerik team
I have an issue in the attached code snippet insertcustomcontrol.zip. What I want is I want to do the load and export functionality without UI. I mean with out actual control is created I have to achieve the functionality.
So I have commented the below code
MainPage.XAML file
<!--<telerik:RadRichTextBox Name="editor" Grid.Row="1" >
<telerik:RadRichTextBox.Document>
<telerik:RadDocument LayoutMode="Paged" />
</telerik:RadRichTextBox.Document>
</telerik:RadRichTextBox>-->
and declared the control like below..
public partial class MainPage : UserControl
{
private RadRichTextBox editor;
private RadDocument document;
...
and modified the event as below...
private void buttonLoadDocumentInEditor_Click(object sender, RoutedEventArgs e)
{
editor =
new RadRichTextBox();
this.editor.Document = document;
}
so...when I build the code it is fine..but I am getting runtime exception when trying to export the doc to "docx" format. I am not having PDF related Dlls as I am using a 2010 version of Telerik.
attached the Error Screen Shot.
Please let me know where the issue is???
Regards,
Ivailo
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
When am going to import the document from docx file to radrichtextbox it is giving exception, that line of code is
this
.RTBox.Document = new DocxFormatProvider().Import(stream);
and error is
Could not load type 'Telerik.Windows.Documents.Packaging.ZipPackage' from assembly 'Telerik.Windows.Documents, Version=2011.3.1020.1040, Culture=neutral, PublicKeyToken=5803cfa389c90ce7'.
can you please help me!
Thanks & Regards,
Nagarjun
In order to use DocxFormatProvider, you also need to reference the Telerik.Windows.Zip dll, which can be found in the same folder where you have installed or extracted the zip with the other assemblies. You can find a list of all required assembly references here.
Note that you must reference the same version of all assemblies and cannot have different versions of Telerik.Windows.Documents and Telerik.Windows.Documents.FormatProviders.OpenXml for example.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
It took me over three hours to find this post. Thanks again for the colossal waste of my time.
Could you please share what information exactly you had troubles finding in the documentation? This forum thread is rather long and multiple topics have been discussed in it. We will make sure to point you to the appropriate resources or in case such are missing, create them.
Thank you for your feedback in advance!
Regards,
Petya
Telerik
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.
I was replying to a post from Boby on March 17 2011 and was referring to the SelectAll() method being used to retrieve a Fragment. There is no documentation in WinForms about how to get a DocumentFragment from the Document.
I ended up using the standard Microsoft RichTextBox anyways; it works better, has better documentation and is easier to use.