Export custom range of code to RTF

SyntaxEditor for WPF Forum

Posted 12 years ago by Kasper
Avatar

Hi guys,

I would like to export a custom range of code to RTF. As far as I can tell from the documentation, you currently only support either exporting the entire document or the selected text. I really think that it would make sense to be able to decide a start and end offset and then export that also. As a workaround, I'm currently creating a new SyntaxEditor instance, copying the language and text from the original SyntaxEditor instance, creating the desired selection and then calling the selection export method, but it's a bit slow, especially for documents with big amounts of text :). I assume that it would be very easy to implement a function like this, since you can already do it for selections, so would it be possible to include in the next release?

Comments (5)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

You can call TextExporters.Rtf.Export(snapshot, new TextRange[] { textRange }) to export any custom text range.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar

That was exactly what I needed! I really wondered why it wasn't mentioned in the documentation, but now as I try to use it, I get a warning that it's obsolete and will be removed in the future. Does that mean that this functionality will be moved to the TextExporterFactory at some point or will it just be completely removed?

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Oops, yes use TextExporterFactory instead to make your IRtfTextExporter.  TextExporterFactory provides the same sort of functionality but also optionally lets you use a custom highlighting style registry.  So it is replacing TextExporters.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar

Excellent, thanks! You might want to mention it in the documentation. I _always_ go there first, but at least to me it wasn't obvious how do accomplish this from reading your otherwise good documentation :)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Thanks, we'll add a section that covers this example too for the next version.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.