Unplanned
Last Updated: 11 Apr 2025 09:33 by ADMIN
Matt
Created on: 11 Apr 2025 09:15
Category: PDFViewer
Type: Feature Request
2
PDF Viewer: Provide support for Paths with Tilings
When document contains paths with tilings, the PDF Viewer does not visualize them, please provide support for this missing feature.
1 comment
ADMIN
Didi
Posted on: 11 Apr 2025 09:33

Solution:

Mainly on PageElementsLoaded event of the PDF Viewer you have to check for tilings and if the tiling has an image as a content, remove the tiling:

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();

		Func<CancellationToken, Task<Stream>> streamFunc = ct => Task.Run(() =>
		{
			Assembly assembly = typeof(MainPage).Assembly;
			string fileName = assembly.GetManifestResourceNames().FirstOrDefault(n => n.Contains("yourdocument.pdf"));
			Stream stream = assembly.GetManifestResourceStream(fileName);
			return stream;
		});
		this.pdfViewer.Source = streamFunc;

		this.pdfViewer.PageElementsLoaded += (s, args) => ReplaceTilingImages(args.Page);
	}

	private static void ReplaceTilingImages(RadFixedPage fixedPage)
	{
		for (int i = 0; i < fixedPage.Content.Count; i++)
		{
			if (fixedPage.Content[i] is Telerik.Windows.Documents.Fixed.Model.Graphics.Path path &&
				path.Fill is Tiling tiling &&
				tiling.Content.Count == 1 &&
				tiling.Content[0] is Telerik.Windows.Documents.Fixed.Model.Objects.Image image)
			{
				var imageCopy = new Telerik.Windows.Documents.Fixed.Model.Objects.Image();
				imageCopy.ImageSource = image.ImageSource;
				imageCopy.Position = tiling.Position;
				fixedPage.Content[i] = imageCopy;
			}
		}
	}
}

Regards,
Didi
Progress Telerik