Display Read-Only PDF Document in C#

PDF viewer component is a reliable solution for developers to disable Copy, Print and Save option with Adobe Reader Component.

What is the best way of embedding adobe pdf document in a C# window from with 100% compatibility? I believe most of you remember the adobe reader addin which allowed loading a pdf file. But all these technologies do not support to do more limitation from modification pdf files.

The following article will show how to load pdf files in a C# application step by step.

The PDF Viewer control for C# can be embedded to add pdf visualization and manipulation capabilities to your C# application. If you haven't the pdf viewer component, you need to install the package firstly.

How to display PDF Document in C# Program

Open the Visual Studio and create a new C# application.

Right Click the Solution. Then click Add Reference... menu item.

C# Add Reference

In the pop up dialog, choose the COM tab.

c# add com

Choose the PDF Viewer Component and Click OK. The PDF Viewer Component References will been added in the new vb.net project.

pdf viewer lib

Switch to the Form design window of Form1.

Switch to the Form design window

Drag the PDF Viewer Component from the Toolbox panel into the form1.

Add PDF Component

Open the Configuration Manager. Change the Active solution platform as x86 option.

x86 option.

Then build the C# project and run.

PDF Component in VB.NET

Disable Copy, Print and Save option

If you want to disable print, copy, save and right click menu in the adobe reader, you need to set permission for the PDF viewer component. This following sample codes demonstrate how it works with Portable Document Format (PDF) files programmatically.

private void DisableToolbarsMenu_Click(object sender, EventArgs e)
{
axPDFViewer1.DisableToolbarRightClickMenu(true);
}

private void DisableViewMenu_Click(object sender, EventArgs e)
{
axPDFViewer1.DisableViewRightClickMenu(true);
}

private void DisableCopy_Click(object sender, EventArgs e)
{
axPDFViewer1.DisableHotKeyCopy();
}

private void DisablePrint_Click(object sender, EventArgs e)
{
axPDFViewer1.DisableHotKeyPrint();
}

private void DisableHotkeys_Click(object sender, EventArgs e)
{
axPDFViewer1.DisableHotKeyCopy();
axPDFViewer1.DisableHotKeyPrint();
axPDFViewer1.DisableHotKeySave();
axPDFViewer1.DisableHotKeyShowBookMarks();
axPDFViewer1.DisableHotKeyShowThumnails();
axPDFViewer1.DisableHotKeyShowToolbars();
axPDFViewer1.SetReadOnly();
}

Embedding MS Office in C# Program

Get Started! Make your application display and interact with MS Office. Try Office Viewer Component
Top