Code: Select all
 private void btnPrintText_Click(object sender, System.EventArgs e)
            {
                  CDIntfEx.CDIntfEx PDF = new CDIntfEx.CDIntfEx(); 
                  PrinterName prt = new PrinterName();
                  prt.PrintN = "Amyuni PDF Converter";
               PDF.DriverInit (prt.PrintN.ToString ());  //Amyuni PDF Converter
                PDF.DefaultFileName = txtSaveFile.Text;
                   PDF.SetDefaultPrinter();
                   
                        PDF.PaperSize = 1;            // letter
                        PDF.Orientation = 1;          // portrait
                        PDF.HorizontalMargin = 0;
                        PDF.VerticalMargin = 0;
                        PDF.Resolution = 1200;
                        PDF.ImageOptions = 1;         // no duplicates
                        PDF.SetDefaultConfigEx();
//These delegates handle messages generated by the PDF Converter
PDF.EndDocPost +=new _DCDIntfEvents_EndDocPostEventHandler(this.mySample);         
//PDF.FileNameOptionsEx = (int) sNoPrompt +  sUseFileName + 0x10 + 0x8000 + 8; //33307
                        int Foex = 0;
                        Foex += 1;             // no dialog
                        Foex += 2;            // use default filename
                        Foex += 8;            // use compression
                        Foex += 0x10;      // embed fonts
                        Foex += 0x200;    // embed full fonts
                        Foex += 0x8000;   
                        PDF.FileNameOptionsEx = Foex;
printDocument1.PrinterSettings.PrinterName = prt.PrintN.ToString();               
                        PDF.CaptureEvents (1); //enable capturing events
 
                        PDF.EnablePrinter (strLicenseTo , strActivationCode );      
                        //Print something
                        printDocument1.Print();
                         //PDF.RestoreDefaultPrinter();
                        //PDF.FileNameOptions = 0;           
            }
            private void mySample()
            {
                  MessageBox.Show ("Document has finished printing");
            }