Some test text!

< Windows samples

PDFViewSimpleTest - C#

This sample shows how to use PDF viewer control in a basic project. The sample uses a number of built-in features from PDFViewCtrl to implement document navigation, text highlighting, markup, and editing. If you are looking for a sample showing how to further customize the viewer (e.g. by implementing custom tools or custom GUI elements), please take a look at PDFView sample project.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

using pdftron;
using pdftron.PDF;
using pdftron.SDF;
using pdftron.Filters;
using pdftron.Common;


namespace PDFViewSimpleCS
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class PDFViewSimple : System.Windows.Forms.Form
    {
        private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();

        private PDFViewCtrl _pdfview;
        private PDFDoc _pdfdoc;
        private String filePath;

        private IContainer components;
        private MainMenu mainMenu1;
        private MenuItem menuItem1;
        private MenuItem MenuFileOpen;
        private MenuItem MenuFileSave;
        private MenuItem MenuFileSaveAs;
        private MenuItem MenuFilePrint;
        private MenuItem MenuFileExit;
        private MenuItem menuItem2;
        private MenuItem MenuEditFind;
        private MenuItem MenuEditCopy;
        private MenuItem MenuEditSelect;
        private MenuItem menuItem3;
        private MenuItem MenuViewPageLayout;
        private MenuItem MenuViewPageView;
        private MenuItem MenuViewZoomIn;
        private MenuItem MenuViewZoomOut;
        private MenuItem MenuViewPageLayoutSingle;
        private MenuItem MenuViewPageLayoutSingleContinuous;
        private MenuItem MenuViewPageLayoutFacing;
        private MenuItem MenuViewPageLayoutFacingContinuous;
        private MenuItem MenuViewPageViewFitPage;
        private MenuItem MenuViewPageViewFitWidth;
        private MenuItem menuItem4;
        private MenuItem MenuToolPan;
        private MenuItem MenuToolStructSel;
        private MenuItem MenuToolRectSel;
        private MenuItem MenuToolRectZoomIn;
        private MenuItem MenuToolRectZoomOut;
        private MenuItem MenuToolAnnotEdit;
        private MenuItem MenuToolLineCreate;
        private MenuItem MenuToolRectCreate;
        private MenuItem MenuToolOvalCreate;
        private MenuItem MenuToolArrowCreate;
        private MenuItem MenuToolFreeHand;
        private MenuItem menuItem5;
        private MenuItem MenuPageNavNext;
        private MenuItem MenuPageNavPrev;
        private MenuItem MenuPageNavFirst;
        private MenuItem MenuPageNavLast;
        private MenuItem menuItem6;
		private System.Windows.Forms.MenuItem menuItemNavPanel;
		private System.Windows.Forms.MenuItem menuItem7;
        private MenuItem menuHelpAbout;
       

		public PDFViewSimple()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			_pdfview = new PDFViewCtrl();
			_pdfview.Location = new System.Drawing.Point(0, 0);
			_pdfview.Dock = System.Windows.Forms.DockStyle.Fill;
            _pdfview.SetPageBorderVisibility(false);
			Controls.Add(_pdfview);
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PDFViewSimple));
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.MenuFileOpen = new System.Windows.Forms.MenuItem();
            this.MenuFileSave = new System.Windows.Forms.MenuItem();
            this.MenuFileSaveAs = new System.Windows.Forms.MenuItem();
            this.MenuFilePrint = new System.Windows.Forms.MenuItem();
            this.MenuFileExit = new System.Windows.Forms.MenuItem();
            this.menuItem2 = new System.Windows.Forms.MenuItem();
            this.MenuEditFind = new System.Windows.Forms.MenuItem();
            this.MenuEditCopy = new System.Windows.Forms.MenuItem();
            this.MenuEditSelect = new System.Windows.Forms.MenuItem();
            this.menuItem3 = new System.Windows.Forms.MenuItem();
            this.MenuViewPageLayout = new System.Windows.Forms.MenuItem();
            this.MenuViewPageLayoutSingle = new System.Windows.Forms.MenuItem();
            this.MenuViewPageLayoutSingleContinuous = new System.Windows.Forms.MenuItem();
            this.MenuViewPageLayoutFacing = new System.Windows.Forms.MenuItem();
            this.MenuViewPageLayoutFacingContinuous = new System.Windows.Forms.MenuItem();
            this.MenuViewPageView = new System.Windows.Forms.MenuItem();
            this.MenuViewPageViewFitPage = new System.Windows.Forms.MenuItem();
            this.MenuViewPageViewFitWidth = new System.Windows.Forms.MenuItem();
            this.MenuViewZoomIn = new System.Windows.Forms.MenuItem();
            this.MenuViewZoomOut = new System.Windows.Forms.MenuItem();
            this.menuItem7 = new System.Windows.Forms.MenuItem();
            this.menuItemNavPanel = new System.Windows.Forms.MenuItem();
            this.menuItem4 = new System.Windows.Forms.MenuItem();
            this.MenuToolPan = new System.Windows.Forms.MenuItem();
            this.MenuToolStructSel = new System.Windows.Forms.MenuItem();
            this.MenuToolRectSel = new System.Windows.Forms.MenuItem();
            this.MenuToolRectZoomIn = new System.Windows.Forms.MenuItem();
            this.MenuToolRectZoomOut = new System.Windows.Forms.MenuItem();
            this.MenuToolAnnotEdit = new System.Windows.Forms.MenuItem();
            this.MenuToolLineCreate = new System.Windows.Forms.MenuItem();
            this.MenuToolRectCreate = new System.Windows.Forms.MenuItem();
            this.MenuToolOvalCreate = new System.Windows.Forms.MenuItem();
            this.MenuToolArrowCreate = new System.Windows.Forms.MenuItem();
            this.MenuToolFreeHand = new System.Windows.Forms.MenuItem();
            this.menuItem5 = new System.Windows.Forms.MenuItem();
            this.MenuPageNavNext = new System.Windows.Forms.MenuItem();
            this.MenuPageNavPrev = new System.Windows.Forms.MenuItem();
            this.MenuPageNavFirst = new System.Windows.Forms.MenuItem();
            this.MenuPageNavLast = new System.Windows.Forms.MenuItem();
            this.menuItem6 = new System.Windows.Forms.MenuItem();
            this.menuHelpAbout = new System.Windows.Forms.MenuItem();
            this.SuspendLayout();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuItem1,
            this.menuItem2,
            this.menuItem3,
            this.menuItem4,
            this.menuItem5,
            this.menuItem6});
            // 
            // menuItem1
            // 
            this.menuItem1.Index = 0;
            this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.MenuFileOpen,
            this.MenuFileSave,
            this.MenuFileSaveAs,
            this.MenuFilePrint,
            this.MenuFileExit});
            this.menuItem1.Text = "File";
            // 
            // MenuFileOpen
            // 
            this.MenuFileOpen.Index = 0;
            this.MenuFileOpen.Text = "Open..";
            this.MenuFileOpen.Click += new System.EventHandler(this.menuFileOpen_Click);
            // 
            // MenuFileSave
            // 
            this.MenuFileSave.Index = 1;
            this.MenuFileSave.Text = "Save";
            this.MenuFileSave.Click += new System.EventHandler(this.MenuFileSave_Click);
            // 
            // MenuFileSaveAs
            // 
            this.MenuFileSaveAs.Index = 2;
            this.MenuFileSaveAs.Text = "Save As";
            this.MenuFileSaveAs.Click += new System.EventHandler(this.MenuFileSaveAs_Click);
            // 
            // MenuFilePrint
            // 
            this.MenuFilePrint.Index = 3;
            this.MenuFilePrint.Text = "Print";
            this.MenuFilePrint.Click += new System.EventHandler(this.MenuFilePrint_Click);
            // 
            // MenuFileExit
            // 
            this.MenuFileExit.Index = 4;
            this.MenuFileExit.Text = "Exit";
            this.MenuFileExit.Click += new System.EventHandler(this.MenuFileExit_Click);
            // 
            // menuItem2
            // 
            this.menuItem2.Index = 1;
            this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.MenuEditFind,
            this.MenuEditCopy,
            this.MenuEditSelect});
            this.menuItem2.Text = "Edit";
            // 
            // MenuEditFind
            // 
            this.MenuEditFind.Index = 0;
            this.MenuEditFind.Text = "Find ...";
            this.MenuEditFind.Click += new System.EventHandler(this.MenuEditFind_Click);
            // 
            // MenuEditCopy
            // 
            this.MenuEditCopy.Index = 1;
            this.MenuEditCopy.Text = "Copy";
            this.MenuEditCopy.Click += new System.EventHandler(this.MenuEditCopy_Click);
            // 
            // MenuEditSelect
            // 
            this.MenuEditSelect.Index = 2;
            this.MenuEditSelect.Text = "Select All";
            this.MenuEditSelect.Click += new System.EventHandler(this.MenuEditSelect_Click);
            // 
            // menuItem3
            // 
            this.menuItem3.Index = 2;
            this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.MenuViewPageLayout,
            this.MenuViewPageView,
            this.MenuViewZoomIn,
            this.MenuViewZoomOut,
            this.menuItem7,
            this.menuItemNavPanel});
            this.menuItem3.Text = "View";
            // 
            // MenuViewPageLayout
            // 
            this.MenuViewPageLayout.Index = 0;
            this.MenuViewPageLayout.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.MenuViewPageLayoutSingle,
            this.MenuViewPageLayoutSingleContinuous,
            this.MenuViewPageLayoutFacing,
            this.MenuViewPageLayoutFacingContinuous});
            this.MenuViewPageLayout.Text = "Page Layout";
            // 
            // MenuViewPageLayoutSingle
            // 
            this.MenuViewPageLayoutSingle.Index = 0;
            this.MenuViewPageLayoutSingle.Text = "Single Page";
            this.MenuViewPageLayoutSingle.Click += new System.EventHandler(this.MenuViewPageLayoutSingle_Click);
            // 
            // MenuViewPageLayoutSingleContinuous
            // 
            this.MenuViewPageLayoutSingleContinuous.Index = 1;
            this.MenuViewPageLayoutSingleContinuous.Text = "Single Continuous";
            this.MenuViewPageLayoutSingleContinuous.Click += new System.EventHandler(this.MenuViewPageLayoutSingleContinuous_Click);
            // 
            // MenuViewPageLayoutFacing
            // 
            this.MenuViewPageLayoutFacing.Index = 2;
            this.MenuViewPageLayoutFacing.Text = "Facing";
            this.MenuViewPageLayoutFacing.Click += new System.EventHandler(this.MenuViewPageLayoutFacing_Click);
            // 
            // MenuViewPageLayoutFacingContinuous
            // 
            this.MenuViewPageLayoutFacingContinuous.Index = 3;
            this.MenuViewPageLayoutFacingContinuous.Text = "Facing Continuous";
            this.MenuViewPageLayoutFacingContinuous.Click += new System.EventHandler(this.MenuViewPageLayoutFacingContinuous_Click);
            // 
            // MenuViewPageView
            // 
            this.MenuViewPageView.Index = 1;
            this.MenuViewPageView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.MenuViewPageViewFitPage,
            this.MenuViewPageViewFitWidth});
            this.MenuViewPageView.Text = "Page View Mode";
            // 
            // MenuViewPageViewFitPage
            // 
            this.MenuViewPageViewFitPage.Index = 0;
            this.MenuViewPageViewFitPage.Text = "Fit Page";
            this.MenuViewPageViewFitPage.Click += new System.EventHandler(this.MenuViewPageViewFitPage_Click);
            // 
            // MenuViewPageViewFitWidth
            // 
            this.MenuViewPageViewFitWidth.Index = 1;
            this.MenuViewPageViewFitWidth.Text = "Fit Width";
            this.MenuViewPageViewFitWidth.Click += new System.EventHandler(this.MenuViewPageViewFitWidth_Click);
            // 
            // MenuViewZoomIn
            // 
            this.MenuViewZoomIn.Index = 2;
            this.MenuViewZoomIn.Text = "Zoom In";
            this.MenuViewZoomIn.Click += new System.EventHandler(this.MenuViewZoomIn_Click);
            // 
            // MenuViewZoomOut
            // 
            this.MenuViewZoomOut.Index = 3;
            this.MenuViewZoomOut.Text = "Zoom Out";
            this.MenuViewZoomOut.Click += new System.EventHandler(this.MenuViewZoomOut_Click);
            // 
            // menuItem7
            // 
            this.menuItem7.Index = 4;
            this.menuItem7.Text = "-";
            // 
            // menuItemNavPanel
            // 
            this.menuItemNavPanel.Index = 5;
            this.menuItemNavPanel.Text = "Navigation Panel";
            this.menuItemNavPanel.Click += new System.EventHandler(this.menuItem7_Click);
            // 
            // menuItem4
            // 
            this.menuItem4.Index = 3;
            this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.MenuToolPan,
            this.MenuToolStructSel,
            this.MenuToolRectSel,
            this.MenuToolRectZoomIn,
            this.MenuToolRectZoomOut,
            this.MenuToolAnnotEdit,
            this.MenuToolLineCreate,
            this.MenuToolRectCreate,
            this.MenuToolOvalCreate,
            this.MenuToolArrowCreate,
            this.MenuToolFreeHand});
            this.menuItem4.Text = "Tool";
            // 
            // MenuToolPan
            // 
            this.MenuToolPan.Index = 0;
            this.MenuToolPan.Text = "Pan";
            this.MenuToolPan.Click += new System.EventHandler(this.MenuToolPan_Click);
            // 
            // MenuToolStructSel
            // 
            this.MenuToolStructSel.Index = 1;
            this.MenuToolStructSel.Text = "Structural Selection";
            this.MenuToolStructSel.Click += new System.EventHandler(this.MenuToolStructSel_Click);
            // 
            // MenuToolRectSel
            // 
            this.MenuToolRectSel.Index = 2;
            this.MenuToolRectSel.Text = "Rectangular Selection";
            this.MenuToolRectSel.Click += new System.EventHandler(this.MenuToolRectSel_Click);
            // 
            // MenuToolRectZoomIn
            // 
            this.MenuToolRectZoomIn.Index = 3;
            this.MenuToolRectZoomIn.Text = "Rectangular Zoom In";
            this.MenuToolRectZoomIn.Click += new System.EventHandler(this.MenuToolRectZoomIn_Click);
            // 
            // MenuToolRectZoomOut
            // 
            this.MenuToolRectZoomOut.Index = 4;
            this.MenuToolRectZoomOut.Text = "Rectangular Zoom Out";
            this.MenuToolRectZoomOut.Click += new System.EventHandler(this.MenuToolRectZoomOut_Click);
            // 
            // MenuToolAnnotEdit
            // 
            this.MenuToolAnnotEdit.Index = 5;
            this.MenuToolAnnotEdit.Text = "Annotation Editing";
            this.MenuToolAnnotEdit.Click += new System.EventHandler(this.MenuToolAnnotEdit_Click);
            // 
            // MenuToolLineCreate
            // 
            this.MenuToolLineCreate.Index = 6;
            this.MenuToolLineCreate.Text = "Line Creation";
            this.MenuToolLineCreate.Click += new System.EventHandler(this.MenuToolLineCreate_Click);
            // 
            // MenuToolRectCreate
            // 
            this.MenuToolRectCreate.Index = 7;
            this.MenuToolRectCreate.Text = "Rectangle Creation";
            this.MenuToolRectCreate.Click += new System.EventHandler(this.MenuToolRectCreate_Click);
            // 
            // MenuToolOvalCreate
            // 
            this.MenuToolOvalCreate.Index = 8;
            this.MenuToolOvalCreate.Text = "Oval Creation";
            this.MenuToolOvalCreate.Click += new System.EventHandler(this.MenuToolOvalCreate_Click);
            // 
            // MenuToolArrowCreate
            // 
            this.MenuToolArrowCreate.Index = 9;
            this.MenuToolArrowCreate.Text = "Arrow Creation";
            this.MenuToolArrowCreate.Click += new System.EventHandler(this.MenuToolArrowCreate_Click);
            // 
            // MenuToolFreeHand
            // 
            this.MenuToolFreeHand.Index = 10;
            this.MenuToolFreeHand.Text = "FreeHand Tool";
            this.MenuToolFreeHand.Click += new System.EventHandler(this.MenuToolFreeHand_Click);
            // 
            // menuItem5
            // 
            this.menuItem5.Index = 4;
            this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.MenuPageNavNext,
            this.MenuPageNavPrev,
            this.MenuPageNavFirst,
            this.MenuPageNavLast});
            this.menuItem5.Text = "Page Navigation";
            // 
            // MenuPageNavNext
            // 
            this.MenuPageNavNext.Index = 0;
            this.MenuPageNavNext.Text = "Go To Next Page";
            this.MenuPageNavNext.Click += new System.EventHandler(this.MenuPageNavNext_Click);
            // 
            // MenuPageNavPrev
            // 
            this.MenuPageNavPrev.Index = 1;
            this.MenuPageNavPrev.Text = "Go To Previous Page";
            this.MenuPageNavPrev.Click += new System.EventHandler(this.MenuPageNavPrev_Click);
            // 
            // MenuPageNavFirst
            // 
            this.MenuPageNavFirst.Index = 2;
            this.MenuPageNavFirst.Text = "Go To First Page";
            this.MenuPageNavFirst.Click += new System.EventHandler(this.MenuPageNavFirst_Click);
            // 
            // MenuPageNavLast
            // 
            this.MenuPageNavLast.Index = 3;
            this.MenuPageNavLast.Text = "Go To Last Page";
            this.MenuPageNavLast.Click += new System.EventHandler(this.MenuPageNavLast_Click);
            // 
            // menuItem6
            // 
            this.menuItem6.Index = 5;
            this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
            this.menuHelpAbout});
            this.menuItem6.Text = "Help";
            // 
            // menuHelpAbout
            // 
            this.menuHelpAbout.Index = 0;
            this.menuHelpAbout.Text = "About ...";
            this.menuHelpAbout.Click += new System.EventHandler(this.menuHelpAbout_Click);
            // 
            // PDFViewSimple
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(619, 443);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Menu = this.mainMenu1;
            this.Name = "PDFViewSimple";
            this.Text = "PDFViewSimple";
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread] 		
		static void Main() 
		{
			PDFNet.Initialize();
			Application.Run(new PDFViewSimple());

		}


		private void menuFileOpen_Click(object sender, System.EventArgs e)
		{
			OpenFileDialog dlg = new OpenFileDialog();
			dlg.CheckFileExists = true;
			dlg.CheckPathExists = true;
			dlg.Filter="PDF (*.pdf)|*.pdf|All files (*.*)|*.*";
			dlg.DefaultExt = ".pdf";

			if(dlg.ShowDialog() == DialogResult.OK) 
			{
				OpenPDF(dlg.FileName); 
			}
		}

		public bool OpenPDF(String filename)
		{
			try 
			{
				PDFDoc oldDoc = _pdfview.GetDoc();
				_pdfdoc = new PDFDoc(filename);
                if (!_pdfdoc.InitSecurityHandler())
                {
                    AuthorizeDlg dlg = new AuthorizeDlg();
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if(!_pdfdoc.InitStdSecurityHandler(dlg.pass.Text))
                        {
                            MessageBox.Show("Incorrect password");
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    }
                }
                _pdfview.SetDoc(_pdfdoc);

                // Example calls to SetupThumbnails:

                // To turn on thumbnail rendering (each 600x600), and retrieving 
                // thumbnails from the pdfs, but no persistent thumbnail caching on disk:
                //_pdfview.SetupThumbnails(true, true, false, 600, "", 0);

                // To cache 100 thumbnails, each 600x600, at "D:\\thumb_cache":
                //_pdfview.SetupThumbnails(true, true, true, 600, "D:\\thumb_cache", 600 * 600 * 4 * 100);
                // To programmatically delete the cache at "D:\\thumb_cache":
                //_pdfview.SetupThumbnails(true, true, true, 600, "D:\\thumb_cache", 0);

                // Example call to GetThumbAsync:
                //PDFViewThumbAsyncDelegate my_del = delegate(int page_num, bool was_thumb_found, System.Drawing.Bitmap thumb_buf, int thumb_width, int thumb_height, object custom_data)
                //{
                //    Console.WriteLine("Inside the callback for GetThumbAsync.");
                //};
                //_pdfview.GetThumbAsync(2, my_del, this);
                
                // Use built-in navigation (thumbnails, bookmarks, layers, etc)?
				// _pdfview.ShowNavToolbar(true);
				// _pdfview.ShowNavPanel(true);

				filePath = filename;
				if (oldDoc != null) 
                {
					oldDoc.Dispose();
				}
			}
			catch(PDFNetException ex)
			{
				MessageBox.Show(ex.Message);
				return false;
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.ToString());
				return false;
			}

			this.Text = filename;  // Set the title
			return true;
		}

	    private void MenuFileSave_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.GetDoc().Save(filePath, SDFDoc.SaveOptions.e_remove_unused);
        }

        private void MenuFileSaveAs_Click(object sender, EventArgs e)
        {
            SaveAs();
        }

        private void SaveAs()
        {
            if (_pdfview.GetDoc() != null)
            {
                SaveFileDialog dlg = new SaveFileDialog();
                dlg.Title = "Save Pdf File";
                dlg.Filter = "PDF (*.pdf)|*.pdf|All files (*.*)|*.*";
                dlg.DefaultExt = ".pdf";

                if (dlg.ShowDialog() == DialogResult.OK)
                    if (dlg.FileName != null)
                        _pdfview.GetDoc().Save(dlg.FileName, SDFDoc.SaveOptions.e_remove_unused);
            }
        }

        private void MenuFilePrint_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.Print();
        }

        private void MenuFileExit_Click(object sender, System.EventArgs e)
        {
            //when the user clicks exit, exit the application
            Application.Exit();
        }

        private void MenuEditFind_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.Find();
        }

        private void MenuEditCopy_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.Copy();
        }

        private void MenuEditSelect_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.SelectAll();
        }

        private void MenuViewPageLayoutSingle_Click(object sender, EventArgs e)
        {
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_single_page);
        }

        private void MenuViewPageLayoutSingleContinuous_Click(object sender, EventArgs e)
        {
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_single_continuous);
        }

        private void MenuViewPageLayoutFacing_Click(object sender, EventArgs e)
        {
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_facing);
        }

        private void MenuViewPageLayoutFacingContinuous_Click(object sender, EventArgs e)
        {
            _pdfview.SetPagePresentationMode(PDFViewCtrl.PagePresentationMode.e_facing_continuous);
        }

        private void MenuViewPageViewFitPage_Click(object sender, EventArgs e)
        {
            _pdfview.SetPageViewMode(PDFViewCtrl.PageViewMode.e_fit_page);
        }

        private void MenuViewPageViewFitWidth_Click(object sender, EventArgs e)
        {
            _pdfview.SetPageViewMode(PDFViewCtrl.PageViewMode.e_fit_width);
        }

        private void MenuViewZoomIn_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.SetZoom(_pdfview.GetZoom() * 2);
        }

        private void MenuViewZoomOut_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.SetZoom(_pdfview.GetZoom() / 2);
        }

        private void MenuToolPan_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_pan);
        }

        private void MenuToolStructSel_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_text_struct_select);
        }

        private void MenuToolRectSel_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_text_rect_select);
        }

        private void MenuToolRectZoomIn_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_zoom_in);
        }

        private void MenuToolRectZoomOut_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_zoom_out);
        }

        private void MenuToolAnnotEdit_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_annot_edit);
        }

        private void MenuToolLineCreate_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_line_create);
        }

        private void MenuToolRectCreate_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_rect_create);
        }

        private void MenuToolOvalCreate_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_oval_create);
        }

        private void MenuToolArrowCreate_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_arrow_create);
        }

        private void MenuToolFreeHand_Click(object sender, EventArgs e)
        {
            _pdfview.SetToolMode(PDFViewCtrl.ToolMode.e_ink_create);
        }

        private void MenuPageNavNext_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.GotoNextPage();
        }

        private void MenuPageNavPrev_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.GotoPreviousPage();
        }

        private void MenuPageNavFirst_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.GotoFirstPage();
        }

        private void MenuPageNavLast_Click(object sender, EventArgs e)
        {
            if (_pdfview.GetDoc() != null)
                _pdfview.GotoLastPage();
        }

        private void menuHelpAbout_Click(object sender, EventArgs e)
        {
            MessageBox.Show(
                "\n\t   PDFViewSimple, Version 1.0\t\n" +
                "\n\t   Copyright (c) 2009\t\n" +
                "\n\tSimple Sample of using PDFViewCtrl in Win32\t\n\n", 
                "About PDFviewSimple");
        }

		private void menuItem7_Click(object sender, System.EventArgs e)
		{
			this.menuItemNavPanel.Checked = !_pdfview.IsNavPanelVisible();
			_pdfview.ShowNavPanel(this.menuItemNavPanel.Checked);
		}

	}
}