Display Read-Only PDF Document in C#
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.
In the pop up dialog, choose the COM tab.
Choose the PDF Viewer Component and Click OK. The PDF Viewer Component References will been added in the new vb.net project.
Switch to the Form design window of Form1.
Drag the PDF Viewer Component from the Toolbox panel into the form1.
Open the Configuration Manager. Change the Active solution platform as x86 option.
Then build the C# project and run.
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();
}