VS 2005

Top  Previous  Next

       

 

       [DllImport("Winspool.drv")]

       private static extern bool SetDefaultPrinter(string printerName);

 

       private void Form1_Load(object sender, EventArgs e)

       {

           //Define a printer name for your application

           string PrinterName = "Application Name";

           int err = 0;

 

           /*

            * If your application requires to create the printer at runtime, Use

            *

            *     axPaperlessPrinterAxPDFX1.PDFDriverInitialize(PrinterName, out err);

            *

            * The above statement requires admin priviledges

            * It is recommended to use this statement in your setup and install the printer before hand

            *

            * Also, the above statment must be followed by,

            *      axPaperlessPrinterAxPDFX1.DriverInitialize(PrinterName, out err);

            * This will ensure that the printer is not deleted when your application is terminated.

            *

            * However, if you do not want the printer to be availble after your application has done with it,

            * Do not use, axPaperlessPrinterAxPDFX1.DriverInitialize(PrinterName, out err);

                *

            */

 

 

           /*

            * If the printer is already installed and you want to use it in your application

            * a call to axPaperlessPrinterAxPDFX1.DriverInitialize(PrinterName, out err);

            * must be done to initialize the driver.

            * 

            */

 

           //Assuming that the printer was installed during the setup

           axPaperlessPrinterAxPDFX1.DriverInitialize(PrinterName, out err);

 

           //axPaperlessPrinterAxPDFX1.SetAsDefault();

 

           SetDefaultPrinter(PrinterName); // WinApi to set the printer as default

 

           //Enable the printer by using your License Key

               axPaperlessPrinterAxPDFX1.SetActivationKey("EMA20-U6XV5-B4Y7A-2253Z-DY63C");

 

           bool isEn = axPaperlessPrinterAxPDFX1.IsPrinterEnabled;

 

               //Check whether the printer is ready to accept and save the document settings                

           if (axPaperlessPrinterAxPDFX1.IsPrinterReady(PrinterName))

           {

 

               axPaperlessPrinterAxPDFX1.FileName = "E:\\Data\\1.pdf";

               axPaperlessPrinterAxPDFX1.CreateNewFolder = false;

 

               //axPaperlessPrinterAxPDFX1.ShowConverionProgress = false;

               //axPaperlessPrinterAxPDFX1.ShowPropertiesDialog = true;

               //axPaperlessPrinterAxPDFX1.ShowSpoolProgress = false;

               //axPaperlessPrinterAxPDFX1.PromptForOverWrite = false;

 

                       //This function has to be called to save the current assigned properties.

                       //A fail to this call, will take the default settings

               axPaperlessPrinterAxPDFX1.SaveSettings();

 

           }

 

           //webBrowser1.Navigate("HTTP_URL");

      }