<< Click to Display Table of Contents >> Navigation: Create a PDF Editor > .NET (C#) Example > Initialize the viewer |
This code is used to initialize the PDF viewer and the main form.
This is what is done here:
1) The usual "InitializeComponent()"
2) Call ViewerStart to set the WPViewPDF license key (please modify unless you use the demo)
3) Set the ViewOptions and ViewControls
4) Call command "commands.COMPDF_ACRO_MAKEDRAWOBJ" to make sure loaded PDF files are displayed with editable fields
5) Call command "commands.COMPDF_Ann_SetAnnotSaveMode" to make sure annotations added to a PDF are saved
6) Call the utility function InitMenu with our menu strip and the first and last predefined menu item.
"doExecuteWPViewAction" will be implemented in next chapter.
public Form1()
{
InitializeComponent();
// Set some properties
pdfViewer1.ViewerStart("xxx", "yyy", 0);
pdfViewer1.ViewOptions = eViewOptions.wpExpandAllBookmarks |
eViewOptions.wpExpandAllBookmarks |
eViewOptions.wpSelectPage |
eViewOptions.wpShowPageSelection;
pdfViewer1.ViewControls =
eViewControls.wpHorzScrollBar |
eViewControls.wpNavigationPanel |
eViewControls.wpPropertyPanel |
eViewControls.wpVertScrollBar |
eViewControls.wpViewPanel;
pdfViewer1.AllowMovePages = true;
// Make sure the annotations work interactively!
pdfViewer1.Command(commands.COMPDF_ACRO_MAKEDRAWOBJ, "", 8192);
// enlarge the zoom buttons
pdfViewer1.Command(commands.COMPDF_SETBUTTONHEIGHT, 32 );
// Standard Action Mode 'Click + Pan'
pdfViewer1.Command(commands.COMPDF_SetActionMode,"",1);
// ENABLE saving of annotations
pdfViewer1.Command(commands.COMPDF_Ann_SetAnnotSaveMode, 1);
// Load the menu from the embedded actions
pdfViewer1.InitMainMenu(menuStrip1,
doExecuteWPViewAction,
fileToolStripMenuItem,
infoToolStripMenuItem);
// Initialize the toolbar
InitToolbar(toolStrip1, _ActionButtons );
}