ByteScout PDF Viewer SDK - C# - Viewer Control Hosted in WPF - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF Viewer SDK – C# – Viewer Control Hosted in WPF

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Viewer SDK – C# – Viewer Control Hosted in WPF

ByteScout PDF Viewer SDK – C# – Viewer Control Hosted in WPF

App.xaml.cs

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace PdfViewerInWpf
{
	/// <summary>
	/// Interaction logic for App.xaml
	/// </summary>
	public partial class App : Application
	{
	}
}

MainWindow.xaml.cs

using System;
using System.Drawing;
using System.Windows;

namespace PdfViewerInWpf
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
		}

		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			// Load a sample document on startup
			pdfViewerControl1.InputFile = "sample.pdf";
		}

		private void menuItemOpen_Click(object sender, RoutedEventArgs e)
		{
			Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog
			{
				Filter = "PDF Files (*.pdf)|*.pdf|All Files (*.*)|*.*"
			};
			
			bool? result = dlg.ShowDialog();

			if (result == true)
				pdfViewerControl1.InputFile = dlg.FileName;
		}
	}
}


  Click here to get your Free Trial version of the SDK

prev
next