Unplanned
Last Updated: 02 Jul 2020 13:37 by ADMIN
n/a
Created on: 02 Jul 2020 13:23
Category: WordsProcessing
Type: Bug Report
0
WordsProcessing: ArgumentException is thrown when exporting a RadFlowDocument that contains an image with an invalid Uri
A possible workaround could be to remove the image with the invalid Uri from the RadFlowDocument before export:
foreach (ImageInline image in document.EnumerateChildrenOfType<ImageInline>().ToList())
{
	UriImageSource uriImageSource = (UriImageSource)image.Image.ImageSource;
	if (uriImageSource != null && !IsValid(uriImageSource.Uri.OriginalString))
	{
		image.Paragraph.Inlines.Remove(image);
	}
}
private static bool IsValid(string uri)
{
	try
	{
		Path.GetExtension(uri);
	}
	catch (ArgumentException)
	{
		return false;
	}

	return true;
}

0 comments