Workaround:
• Subscribe to the PageElementsLoaded
• Get the page (e.Page, a RadFixedPage) and calls RecolorRadialShading(page.Content) to alter its content.
• If an element is a Path whose Fill is a RadialGradient (PDF shading type 3), it replaces the fill with solid white (new RgbColor(255, 255, 255)) — effectively neutralizing/hiding the radial shading.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
RadFixedDocument document = ImportBackBaseDocument();
this.pdfViewer.PageElementsLoaded += OnPageElementsLoaded;
this.pdfViewer.Source = new FixedDocumentSource(document);
}
private void OnPageElementsLoaded(object sender, PageElementsLoadedEventArgs e)
{
RadFixedPage page = e.Page;
if (page is not null)
{
RecolorRadialShading(page.Content);
}
}
// Walks the page content, recursing into MarkedContent containers, and
// recolors any Path whose Fill is a RadialGradient (PDF shading type 3).
private static void RecolorRadialShading(ContentElementCollection content)
{
if (content is null)
{
return;
}
foreach (var element in content)
{
switch (element)
{
case GraphicsPath path when path.Fill is RadialGradient:
path.Fill = new RgbColor(255, 255, 255);
break;
case MarkedContent marked:
RecolorRadialShading(marked.Content);
break;
}
}
}
private static RadFixedDocument ImportBackBaseDocument()
{
Assembly assembly = typeof(MainPage).Assembly;
string fileName = assembly.GetManifestResourceNames()
.FirstOrDefault(n => n.Contains("yourpdf_file.pdf"));
using Stream stream = assembly.GetManifestResourceStream(fileName);
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
PdfFormatProvider formatProvider = new PdfFormatProvider();
return formatProvider.Import(memoryStream.ToArray(), TimeSpan.FromMilliseconds(200));
}
}Regards,
Didi
Progress Telerik