title: Printing from Adobe with Citrix
body: <p>Greetings, </p>
  
  <p>I've attempted to shrink the code down as much as I can.  Basically we use the Adobe Acrobat standard 6 Com libraries to print.  It works as well as any batch pdf print solution that I've seen, but I can't seem to make it work with Citrix.  Citrix appears to remap the netowrk printing locations and I can't seem to make it work with out existing solution.  All the code runs on Citirix it just doesn't print anything.  When it runs locally it runs and prints just fine.</p>
  
  <p>Any help would be greatly appreciated,</p>
  
  <p>Thank you, 
  Brian </p>
  
  <pre><code>private void btnTest_Click(object sender, EventArgs e)
  {
      try
      {
          Cursor.Current = Cursors.WaitCursor;
  
          PrintDialog PrintDialog1 = new PrintDialog();
          PrintDialog1.ShowDialog();
  
          CAcroAVDoc acroDoc = null;
  
          const string fileName = @"SomeFile.pdf";
  
          var acroApp = instantiateAcrobat();
          acroDoc = GetAcrobatAVDoc();
  
          acroDoc.Open(fileName, "");
  
          CAcroPDDoc pdDoc = (CAcroPDDoc)acroDoc.GetPDDoc();
          int numPages = pdDoc.GetNumPages();
  
          UnManagedMethods.SetDefaultPrinter(PrintDialog1.PrinterSettings.PrinterName);
  
          acroDoc.PrintPagesSilent(0, numPages - 1, 2, 1, 0);
  
          MessageBox.Show("Printed!!");
      }
      catch (Exception ex) 
      {
          MessageBox.Show(ex.Message);
      }
  }
  
  private static CAcroAVDoc GetAcrobatAVDoc()
  {
      Type acroApp = Type.GetTypeFromProgID("AcroExch.AVDoc", true);
      return (CAcroAVDoc)Activator.CreateInstance(acroApp);
  }
  
  private static CAcroApp instantiateAcrobat()
  {
      killAllAcrobatProcesses();
      Type acroApp = Type.GetTypeFromProgID("AcroExch.App", true);
      return (CAcroApp)Activator.CreateInstance(acroApp);
  }
  
  private static void killAllAcrobatProcesses()
  {
      Process[] acrobatProcesses = Process.GetProcessesByName("Acrobat");
      if (acrobatProcesses.Length &gt; 0)
      {
          foreach (Process process in acrobatProcesses)
          {
              process.Kill();
          }
      }
      Process[] acroRd32Processes = Process.GetProcessesByName("AcroRd32");
      if (acroRd32Processes.Length &gt; 0)
      {
          foreach (Process process in acroRd32Processes)
          {
              process.Kill();
          }
      }
  }
  </code></pre>