Articles in this section
Category / Section

How to apply localization for a WPF PdfViewer hosted in WinForms Application

3 mins read

To implement localization for the WPF PDF Viewer embedded within a WinForms application, the process involves hosting the WPF PDF Viewer in WinForms. For guidance on hosting, refer to the Hosting WPF in WinForms documentation.

To accomplish localization, begin by creating a new class library within your WinForms solution. Inside this library, create a folder named “Resources” and add the necessary .resx files for localization. Then, reference this class library in your WinForms project. In the WPF UserControl hosting the PDF Viewer, include code to load and apply localization resources from the referenced assembly.

Steps to Apply Localization for a WPF PDF Viewer Hosted in a WinForms Application

Step 1:
Create a new class project and add a “Resources” folder to the class project. Place the default English resource file (Syncfusion.PdfViewer.WPF.resx) in the Resources folder. Create additional .resx files to support different cultures. For example:

  • Syncfusion.PdfViewer.WPF.en.resx for English
  • Syncfusion.PdfViewer.WPF.fr.resx for French

Step 2:
In each .resx file, define the required resource keys and their corresponding localized values. Add the created class library as a reference to your WinForms application.

Step 3:
Create a WPF UserControl that includes the PdfViewerControl. Embed this control into the WinForms application using ElementHost. Configure localization by linking the external resource assembly using the LocalizationManager.SetResources method.

// Set the custom class library assembly and namespace for localization
LocalizationManager.SetResources(
    typeof(LocalizationClassLibrary.Class1).Assembly,
    "LocalizationClassLibrary"
);

// Load the document
pdfViewer.Load(@"../../Data/F#.pdf");

A fully functional example demonstrating the localization of a WPF PDF Viewer hosted in a WinForms application can be downloaded from GitHub.

Conclusion:
This guide explains how to apply localization for a WPF PDF Viewer hosted within a WinForms application. For more information about the features of the WinForms PDF Viewer, visit the WinForms PDF Viewer page. You can also review the WinForms PDF Viewer documentation for details on presenting and manipulating data.

Existing customers can access components through the License and Downloads page. New users can explore Syncfusion® controls with a 30-day free trial.

For further inquiries or feedback, feel free to comment below or contact us via our support forums, Direct-Trac, or feedback portal. We are always happy to assist!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied