Thanks.
7 Answers, 1 is accepted
There are no customization options for the way XamlFormatProvider serializes the document.
Could you provide some more details on the customization options you would find convenient in this scenario?
Looking forward to your reply.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thank you.
We will add ExportSettings for XamlFormatProvider, the way it has been done for HtmlFormatProvider, RtfFormatProvider and PdfFormatProvider. More information on the way export settings are used can be found here. We will probably implement the same mechanism which has been implemented for HtmlFormatProvider - introducing an InlineUIContainerExporting event. In this way, it will be possible to handle the event and provide your implementation in place of the default one.
When the feature is implemented, we will make sure to update the article to include XamlFormatProvider.
Please, let us know if you find this solution appropriate.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
There is no customization point that prevents the export of FloatingImageBlocks to PDF.
With HtmlFormatProvider, we have provided such settings because it is useful in the cases when you want to export and import images separately and reference them in the HTML using a URI such as a relative path to the image. As HTML is a text-based format, one could implement this functionality in a quite straightforward way.
When it comes to the PdfExportSettings, as you have noticed in the ticket you opened, the InlineUIContainersExportMode setting is not applied, i.e. InlineUIContainers are always exported as images. We will fix this behavior, but providing a customization option for images is not considered at this point. You can, however, remove the images from the document before export. Please, refer to the sample application attached in the ticket, which performs the same operation for InlineUIContainers.
Iva Toteva
the Telerik team
There are two ways to accomplish the export of the document without the images.
The first one is to create a copy of the document, iterate through it deleting the images and export the result. Using this approach, you can remove the images from the paragraph using the document collection like this:
image.Parent.Children.Remove(image);
The second option is not to create a copy of the document and delete the images in the editor. The time for copying the document will be spared, but you will have to delete the images using the Delete method of RadRichTextBox in order to preserve the history. This can be done like this:
IEnumerable<FloatingImageBlock> floatingImageBlocks =
this
.AssociatedRichTextBox.Document.EnumerateChildrenOfType<FloatingImageBlock>();
foreach
(var imageBlock
in
floatingImageBlocks)
{
DocumentPosition start =
new
DocumentPosition(
this
.AssociatedRichTextBox.Document);
DocumentPosition end =
new
DocumentPosition(
this
.AssociatedRichTextBox.Document);
InlineLayoutBox inlineLayoutBox = imageBlock.FirstLayoutBox
as
InlineLayoutBox;
InlineLayoutBox nextLayoutBox = inlineLayoutBox.AssociatedInline.NextSibling.FirstLayoutBox
as
InlineLayoutBox;
start.MoveToInline(inlineLayoutBox, 0);
end.MoveToInline(nextLayoutBox, 0);
this
.AssociatedRichTextBox.Document.Selection.SetSelectionStart(start);
this
.AssociatedRichTextBox.Document.Selection.AddSelectionEnd(end);
this
.AssociatedRichTextBox.Delete(
false
);
deletedImages++;
}
You can execute this code in a save command you have created and wired the UI to work with. After the export is complete, you can undo the changes:
for
(
int
i = 0; i < deletedImages; i++)
{
this
.AssociatedRichTextBox.Undo();
}
This method for deleting the images is slower because RadRichTextBox creates contexts for the execution of the commands in order to be able to undo and redo the changes to the document. Furthermore, the
You can choose which method will be more appropriate in your application depending on the size of the documents and the number of floating images that will normally be present in the document. All the best,
Iva Toteva
the Telerik team