public void PrintActiveViewArcPressParameterized(int iResampleRatio)
    {

      /* Prints the Active View of the document with ArcPress */
      IPrintAndExport PrintAndExport = new PrintAndExportClass();
      IActiveView docActiveView = ArcMap.Document.ActiveView;
      IPrinter docPrinter;
      IArcPressPrinter docArcPressPrinter;
      string sNameRoot;
      short iNumPages;

      // assign the output path and filename.  We can use the Filter property of the export object to
      // automatically assign the proper extension to the file.
      sNameRoot = ArcMap.Application.Document.Title.Substring(0, ArcMap.Application.Document.Title.Length - 4);

      //create new ArcPress printer classes
      docPrinter = new ArcPressPrinterClass();
      docArcPressPrinter = new ArcPressPrinterClass();

      try
      {
          //auto-select the driver based on the printer's name.
          docArcPressPrinter.AutoSelectDriverByName(ArcMap.ThisApplication.Paper.PrinterName);

          //if the printer cannot be auto-selected, exit.
          if (docArcPressPrinter.SelectedDriverId == null)
          {
              MessageBox.Show("Could not auto-select ArcPress driver for printer");
              return;
          }

          //transfer the ArcPress printer properties into docPrinter
          docPrinter = (IPrinter)docArcPressPrinter;

          //the paper should be the same as the application's paper.
          docPrinter.Paper = ArcMap.ThisApplication.Paper;

          //make sure the paper orientation is set to the orientation matching the current view.
          docPrinter.Paper.Orientation = ArcMap.Document.PageLayout.Page.Orientation;

          //set the spool filename (this is the job name that shows up in the print queue)
          docPrinter.SpoolFileName = sNameRoot;

          // Find out how many printer pages the output will cover.  iNumPages will always be 1 
          // unless the user explicitly sets the tiling options in the file->Print dialog.  
          if (ArcMap.Document.ActiveView is IPageLayout)
          {
              ArcMap.Document.PageLayout.Page.PrinterPageCount(docPrinter, 0, out iNumPages);
          }
          else
          {
              iNumPages = 1;
          }


          for (short lCurrentPageNum = 1; lCurrentPageNum <= iNumPages; lCurrentPageNum++)
          {

              //the StepProgressor is what creates the bar graph of the print's progress.
              docPrinter.StepProgressor = ArcMap.Application.StatusBar.ProgressBar;
              try
              {
                  PrintAndExport.Print(ArcMap.Document.ActiveView, docPrinter, ArcMap.Document.PageLayout.Page, lCurrentPageNum, iResampleRatio, null);
              }
              catch
              {
                  MessageBox.Show("Error printing page " + lCurrentPageNum);
              }

          }

      }
      catch 
      {
          MessageBox.Show("Could not auto-select ArcPress driver for this printer");
      }
      
    }
示例#2
0
        public void PrintActiveViewArcPressParameterized(int iResampleRatio)
        {
            /* Prints the Active View of the document with ArcPress */
            IPrintAndExport  PrintAndExport = new PrintAndExportClass();
            IActiveView      docActiveView  = ArcMap.Document.ActiveView;
            IPrinter         docPrinter;
            IArcPressPrinter docArcPressPrinter;
            string           sNameRoot;
            short            iNumPages;

            // assign the output path and filename.  We can use the Filter property of the export object to
            // automatically assign the proper extension to the file.
            sNameRoot = ArcMap.Application.Document.Title.Substring(0, ArcMap.Application.Document.Title.Length - 4);

            //create new ArcPress printer classes
            docPrinter         = new ArcPressPrinterClass();
            docArcPressPrinter = new ArcPressPrinterClass();

            try
            {
                //auto-select the driver based on the printer's name.
                docArcPressPrinter.AutoSelectDriverByName(ArcMap.ThisApplication.Paper.PrinterName);

                //if the printer cannot be auto-selected, exit.
                if (docArcPressPrinter.SelectedDriverId == null)
                {
                    MessageBox.Show("Could not auto-select ArcPress driver for printer");
                    return;
                }

                //transfer the ArcPress printer properties into docPrinter
                docPrinter = (IPrinter)docArcPressPrinter;

                //the paper should be the same as the application's paper.
                docPrinter.Paper = ArcMap.ThisApplication.Paper;

                //make sure the paper orientation is set to the orientation matching the current view.
                docPrinter.Paper.Orientation = ArcMap.Document.PageLayout.Page.Orientation;

                //set the spool filename (this is the job name that shows up in the print queue)
                docPrinter.SpoolFileName = sNameRoot;

                // Find out how many printer pages the output will cover.  iNumPages will always be 1
                // unless the user explicitly sets the tiling options in the file->Print dialog.
                if (ArcMap.Document.ActiveView is IPageLayout)
                {
                    ArcMap.Document.PageLayout.Page.PrinterPageCount(docPrinter, 0, out iNumPages);
                }
                else
                {
                    iNumPages = 1;
                }


                for (short lCurrentPageNum = 1; lCurrentPageNum <= iNumPages; lCurrentPageNum++)
                {
                    //the StepProgressor is what creates the bar graph of the print's progress.
                    docPrinter.StepProgressor = ArcMap.Application.StatusBar.ProgressBar;
                    try
                    {
                        PrintAndExport.Print(ArcMap.Document.ActiveView, docPrinter, ArcMap.Document.PageLayout.Page, lCurrentPageNum, iResampleRatio, null);
                    }
                    catch
                    {
                        MessageBox.Show("Error printing page " + lCurrentPageNum);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Could not auto-select ArcPress driver for this printer");
            }
        }