Initialize Program

<< Click to Display Table of Contents >>

Navigation:  Create a PDF Editor > .NET (C#) Example >

Initialize Program

Make sure windows does not display the form blurred on high dpi - we set the DPI-Aware flag in Program.cs.

 

We also specify the engine DLL which should be used by the application using

   WPViewPDF.PDFViewer.SetDLLName.

 

To check wether the program runs with 64bit ot 32 bit we check the size of an IntPtr.

 

 

  static class Program

   {

       [System.Runtime.InteropServices.DllImport("user32.dll")]

      private static extern bool SetProcessDPIAware();

 

       [STAThread]

      static void Main()

       {

          // This code makes sure the form is not blurred on high DPI

          if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();

 

          // Set the name of the WPViewPDF Engine DLL which should be loaded

          WPViewPDF.PDFViewer.SetDLLName(

                // This is the basis directoy of the application

                AppDomain.CurrentDomain.BaseDirectory +

                // This is the engine DLL - please modify!

                // wPDFViewDemo05, wPDFView04 or wPDFViewPlus05

                "wPDFViewDemo05" +

                // If we run under 64bit system add "x64"  

                ((System.Runtime.InteropServices.Marshal.SizeOf(

                              new IntPtr()) == 8)? "x64.dll" : ".dll")

              );

 

          Application.EnableVisualStyles();

          Application.SetCompatibleTextRenderingDefault(false);

          Application.Run(new Form1());

       }

   }

 

 

Please note: Once a viewer was created on a form, use ViewerStart to set the licensing information.

   pdfViewer1.ViewerStart("xxx", "yyy", 0);