Need to generate Docx, HTML, RTF or PDF documents in your Xamarin App? Telerik UI for Xamarin has a solution for you - our new WordsProcessing library.
It has never been easier to generate, modify and export a document in your mobile application! The RadWordsProcessing library enables you to easily generate and export documents in various formats, including:
The library comes in handy all cases where document or PDF generation is needed, such as PDF invoice generation for an e-commerce app, or to serve the user with a filled application form in Docx format.
With our document processing library you can quickly access each element in a given document, modify, remove it or add a new one. Additionally, the generated content can be saved as a stream, file, or send to the client browser.
In this blog post, we will familiarize you with the RadWordsProcessing structure and the features it provides.
The document model of RadWordsProcessing for Xamarin includes all necessary elements and features of a document, including:
In addition to the smooth creation, modification, import and export of files, RadWordsProcessing gives you the ability to convert between variety of formats - convert Docx to PDF or HTML to Docx in your Xamarin apps. The currently supported formats are Docx, RTF, HTML, PDF and plain text.
The processing library doesn’t need any external dependencies in order to convert documents from/to the supported formats - the document model is UI-independent and can be used on both server and client-side.
In addition to being able to create, modify, and export a document, RadWordsProcessing has some additional sweet features, including:
private
RadFlowDocument CreateDocument()
{
RadFlowDocument document =
new
RadFlowDocument();
RadFlowDocumentEditor editor =
new
RadFlowDocumentEditor(document);
editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Justified;
editor.InsertLine(
"Dear Telerik User,"
);
editor.InsertText(
"We’re happy to introduce the new Telerik RadWordsProcessing component for Xamarin Forms. High performance library that enables you to read, write and manipulate documents in DOCX, RTF and plain text format. The document model is independent from UI and "
);
Run run = editor.InsertText(
"does not require"
);
run.Underline.Pattern = UnderlinePattern.Single;
editor.InsertLine(
" Microsoft Office."
);
editor.InsertText(
"The current community preview version comes with full rich-text capabilities including "
);
editor.InsertText(
"bold, "
).FontWeight = FontWeights.Bold;
editor.InsertText(
"italic, "
).FontStyle = FontStyles.Italic;
editor.InsertText(
"underline,"
).Underline.Pattern = UnderlinePattern.Single;
editor.InsertText(
" font sizes and "
).FontSize = 20;
editor.InsertText(
"colors "
).ForegroundColor = GreenColor;
editor.InsertLine(
"as well as text alignment and indentation. Other options include tables, hyperlinks, inline and floating images. Even more sweetness is added by the built-in styles and themes."
);
editor.InsertText(
"Here at Telerik we strive to provide the best services possible and fulfill all needs you as a customer may have. We would appreciate any feedback you send our way through the "
);
editor.InsertHyperlink(
"public forums"
,
"http://www.telerik.com/forums"
,
false
,
"Telerik Forums"
);
editor.InsertLine(
" or support ticketing system."
);
editor.InsertLine(
"We hope you’ll enjoy RadWordsProcessing as much as we do. Happy coding!"
);
editor.InsertParagraph();
editor.InsertText(
"Kind regards,"
);
return
document;
}
private
void
ReplaceText()
{
if
(
string
.IsNullOrEmpty(
this
.findWhat))
{
return
;
}
RadFlowDocumentEditor editor =
new
RadFlowDocumentEditor(
this
.replacedDocument);
if
(
this
.useRegex)
{
Regex oldTextRegex =
new
Regex(
this
.findWhat);
editor.ReplaceText(oldTextRegex,
this
.replaceWith);
}
else
{
editor.ReplaceText(
this
.findWhat,
this
.replaceWith,
this
.matchCase,
this
.matchWholeWord);
}
}
The full demo project can be found here.
RadFlowDocument target =
new
RadFlowDocument();
RadFlowDocument source =
new
RadFlowDocument();
//...
// target will contain merged content and styles.
target.Merge(source);
Here the document you wish to add content to is called target and the document from which you wish to take the content is called source.
Export documents in different formats:
Have we caught your interest with the new RadWordsProcessing library for Xamarin.Forms and its features? You can find various demos of the processing library in our Telerik UI for Xamarin Demo application.
I hope that this information will get you started with the processing library— as always, any feedback on it is highly appreciated. If you have any ideas for features, not hesitate to share this information with us on our Telerik Document Processing Feedback Portal.
If this is the first time you're hearing about Telerik UI for Xamarin, you can find more information about it on our website or dive right into a free 30-day trial today.
Happy coding with our controls!
Dobrinka Yordanova is a Technical Support Engineer, part of the Progress Telerik UI for Xamarin & UWP team in Sofia, Bulgaria. She holds a master's degree in Computer Systems and Technologies. Her passion is traveling around the world and exploring multicultural environments. In her spare time she likes making sushi, playing console games and hanging out with friends.