Telerik Forums
UI for WPF Forum
0 answers
8 views

We are using WPF with Prism, MEF, and Telerik controls (PdfViewer and GridView, version 2017.2.503.45). Our application loads multiple tab views dynamically using the MVVM pattern. Each view contains multiple Telerik controls, and their data is bound from the ViewModel.

The issue we are facing is that when a tab is closed, the Telerik controls still hold references to the associated ViewModel, preventing the memory from being released.

We have tried the following approaches while closing the tab:

RadPdfViewer.DataContext = null;

RadPdfViewer = null;

RadGridView.DataContext = null;

RadGridView = null;

We also tried disposing of the Telerik controls, but the memory is still retained by them.

We have also defined the PdfViewer in XAML, but no PDF file was ever loaded into it from the UI. However, even in this case, the XAML view is not being disposed when the tab is closed, and the PdfViewer still holds a reference to the view.

 

Could you please help us identify how to properly release memory and ensure the controls? 

 

Srinivasan
Top achievements
Rank 1
 asked on 18 Sep 2025
1 answer
12 views

Hi,

I have this code, thats not working like this.

Because of the DataContext, the DocumentSource wont work, because it needs obviously a different DataContext.
But I need this DataContext for the ContextMenu to work.

Is there a way I can have both? A working context menu and also bind the DocumentSource?

Greetings
Benedikt

        <telerik:RadPdfViewerToolBar 
            Grid.Row="1"
            x:Name="pdfViewerToolBarZeichnungen" 
            Margin="0 5 0 0"
            RadPdfViewer="{Binding ElementName=pdfViewerZeichnungen}" 
            HasSaveButton="{DynamicResource SonderRechtPDFsSpeichernErlaubt}" 
            HasSignatureButton="False" 
            HasPercentComboBox="False" 
            HasPrintButton="{DynamicResource SonderRechtPDFsSpeichernErlaubt}" 
            />
        <telerik:RadPdfViewer 
            Grid.Row="2" 
            x:Name="pdfViewerZeichnungen" 
            DocumentSource="{Binding SelDatei.FilePath, Converter={StaticResource PdfDocumentSourceValueConverter}}"
            DataContext="{Binding CommandDescriptors, ElementName=pdfViewerZeichnungen}" 
            telerik:RadPdfViewerAttachedComponents.RegisterFindDialog="True" 
            telerik:RadPdfViewerAttachedComponents.RegisterContextMenu="True"
            Mode="TextSelection"
            >


Stenly
Telerik team
 answered on 18 Aug 2025
2 answers
10 views
Is there anyway to disable this functionality in the pdf viewer so that I can handle zooming manually?
Rob
Top achievements
Rank 2
Iron
Iron
Iron
 answered on 22 Jul 2025
0 answers
16 views
Hello, 
I'm trying to merge several PDF files into one and then print them.
I am using version 2022.2.621.

My code looks like this



       public static void Print(List<string> files)
       {
           using (MemoryStream stream = new MemoryStream())
           {
               using (PdfStreamWriter fileWriter = new PdfStreamWriter(stream, leaveStreamOpen: true))
               {
                   foreach (string path in files)
                   {
                       using (PdfFileSource fileSource = new PdfFileSource(new MemoryStream(File.ReadAllBytes(path))))
                       {
                           for (int i = 0; i < fileSource.Pages.Length; i++)
                           {
                               PdfPageSource sourcePage = fileSource.Pages[i];
                               using (PdfPageStreamWriter resultPage = fileWriter.BeginPage(sourcePage.Size))
                               {
                                   // set content                      
                                   resultPage.WriteContent(sourcePage);
                               }
                           }
                       }
                   }
               }

               var pdfViewer = new RadPdfViewer();
               PdfFormatProvider provider = new PdfFormatProvider();
               RadFixedDocument document = provider.Import(stream);
               pdfViewer.Document = document;
               var printdlg = new PrintDialog();
               printdlg.UserPageRangeEnabled = true;
               printdlg.SelectedPagesEnabled = true;
               if (printdlg.ShowDialog() == true)
               {
                   var printSettings = new PrintSettings(Path.GetFileNameWithoutExtension("file"), false);
                   pdfViewer.Print(printdlg, printSettings);
               }
           }
       }

My problem is, that befor print pdf looks like this

But after print



What I discoverd, that file befor print has more fonts then after.
Befor:


After



How can I handle this problem?
John
Top achievements
Rank 1
 asked on 08 Jul 2025
1 answer
195 views

   I have a PDF file that's been imported into a MemoryStream object and now I need to display it using the Telerik UI for WPF pdfViewer control.  The existing documentation says that you can create a PdfDocumentSource object and bind the pdfViewer.DocumentSource to that.  However, either PdfDocumentSource no longer exists, or I can't figure out what the correct Namespace is.

   I'm using TelerikUI for WPF v2024 Q2.  However changelogs for 2020 (https://docs.telerik.com/devtools/wpf/controls/radpdfviewer/changes-and-backward-compatibility/backward-compatibility)  say that: 

Changed
Obsolete constructors of Telerik.Windows.Documents.Fixed.PdfDocumentSource:

PdfDocumentSource(Uri uri, FormatProviderSettings settings)
PdfDocumentSource(Stream stream, FormatProviderSettings settings)
What to do now
Use the overloads that accept Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.PdfImportSettings instead.

   I've also read that there is some kind of merge going on trying to replace the previous PDF code with Telerik.Windows.Documents.Fixed .  In any case, I can't seem to figure out how to go from a MemoryStream to something that the pdfViewer.DocumentSource likes.  

   Can anyone help with a very basic code sample to take a PDF as a memorystream and create something that pdfView.DocumentSource will accept?  Thank you!

 

Dimitar
Telerik team
 answered on 07 Jun 2024
1 answer
73 views

Hey,

as in the titel is there a event or workaround to know if a userer startet to type inside a pdf text field. I just need it to set a bool true to inform the user that there is a possibility to lose data.

 

Thanks

Dominik

Dimitar
Telerik team
 answered on 28 Mar 2024
1 answer
84 views

As in the title it doesnt work so the movement on the document isnt great.

 

Thanks for the help

Dominik

Dimitar
Telerik team
 answered on 12 Mar 2024
0 answers
59 views

As in the title some charactes are getting not displayed in some pdfs.

If I import this pdf: https://jmp.sh/s/mdWM2qNDL2Oi6Yd825s0

Im getting this result its right if you click inside the field but its not getting displayed correct when not inside the field

 

Maybe its something with the font, thats the only thing i could think of.

 

Thanks for the help

Dominik

 

 

Dominik
Top achievements
Rank 1
Iron
Iron
 updated question on 21 Feb 2024
1 answer
84 views

Hey im using the telerik PercentComboBox and i want to change language of the FitToPage and FitToWidthto be displayed in german.

 

  <telerik:PercentComboBox DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type local:DialogControl}}}"
                           Value="{Binding ScaleFactor,ElementName=pdfViewer, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                           RadPdfViewer="{Binding ElementName=pdfViewer}" ShowFitToWidth="True" ShowFitToPage="True"
                           telerik:Windows11ThemeSizeHelper.EnableDynamicAnimation="True" Language="de-DE">
      <telerik:PercentComboBox.PercentValues>
          <telerik:Percent Value="200"/>
          <telerik:Percent Value="150"/>
          <telerik:Percent Value="125"/>
          <telerik:Percent Value="110"/>
          <telerik:Percent Value="100"/>
          <telerik:Percent Value="90"/>
          <telerik:Percent Value="75"/>
          <telerik:Percent Value="50"/>
          <telerik:Percent Value="30"/>
      </telerik:PercentComboBox.PercentValues>
  </telerik:PercentComboBox>

 

Hope there is a way. Thanks

Dominik

Stenly
Telerik team
 answered on 12 Dec 2023
1 answer
107 views

Hey,

I have set my TextField to ReadOnly but the RadPdfViewer doesnt react to it. Im getting a pdf File that im importing using the telerik PdfFormatProvider after that im trying to set some of the fields to readOnly like this: 

if (formField is TextBoxField textBox)
{
	if (field is not null)
	{
	
		textBox.Value = field.ViewValue(viewMode);
		if (field.VarType != 0)
			formField.IsReadOnly = true;
			
	}
}

 

Im sure its setting it because if i export it to a pdf the fields are set to ReadOnly but not in the Telerik PdfViewer

 

Thanks

Dominik

Martin Ivanov
Telerik team
 answered on 01 Dec 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?