void SendToPrinter(int fromPage, int toPage)
        {
            bool    firstPass = true;
            DOCINFO di        = new DOCINFO();
            IntPtr  ptr       = new IntPtr();

            di.pDocName  = document.DocumentName;
            di.pDataType = "RAW";
            PrintDirect.OpenPrinter(printerName, ref ptr, 0);
            PrintDirect.StartDocPrinter(ptr, 1, ref di);
            for (int i = fromPage - 1; i < toPage; i++)
            {
                PrintDirect.StartPagePrinter(ptr);
                if (firstPass)
                {
                    Print(ptr, PageSetting());
                    firstPass = false;
                }
                Print(ptr, document.ToString(i));
                Print(ptr, "\f");
                PrintDirect.EndPagePrinter(ptr);
            }
            //Print(ptr, PageSetting());
            //Print(ptr, "****hello world\n");
            //Print(ptr, "****hello world\f");
            PrintDirect.EndDocPrinter(ptr);
            PrintDirect.ClosePrinter(ptr);
        }
Example #2
0
 public static extern long StartDocPrinter(IntPtr hPrinter, int Level, ref DOCINFO pDocInfo);
 void SendToPrinter(int fromPage, int toPage)
 {
     bool firstPass = true;
     DOCINFO di = new DOCINFO();
     IntPtr ptr = new IntPtr();
     di.pDocName = document.DocumentName;
     di.pDataType = "RAW";
     PrintDirect.OpenPrinter(printerName, ref ptr, 0);
     PrintDirect.StartDocPrinter(ptr, 1, ref di);
     for (int i = fromPage - 1; i < toPage; i++)
     {
         PrintDirect.StartPagePrinter(ptr);
         if (firstPass)
         {
             Print(ptr, PageSetting());
             firstPass = false;
         }
         Print(ptr, document.ToString(i));
         Print(ptr, "\f");
         PrintDirect.EndPagePrinter(ptr);
     }
     //Print(ptr, PageSetting());
     //Print(ptr, "****hello world\n");
     //Print(ptr, "****hello world\f");
     PrintDirect.EndDocPrinter(ptr);
     PrintDirect.ClosePrinter(ptr);
 }
 public static extern long StartDocPrinter(IntPtr hPrinter, int Level, ref DOCINFO pDocInfo);