title: Set Selenium ChromeDriver UserPreferences to Save as PDF
body: <p>I am using ChromeDriver 2.33 and am using kiosk printing to automatically click the Print button on the Print Preview dialog however it is sending the document to the printer instead of PDF.</p>
  
  <p>I have attempted the solution at <a href="https://stackoverflow.com/questions/15824996/how-to-set-chrome-preferences-using-selenium-webdriver-net-binding/47007664#47007664">this stack overflow question</a> to no avail.</p>
  
  <p>Here is the code I am using:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>ChromeOptions o = new ChromeOptions();
  o.AddArgument("--kiosk-printing");
  o.AddUserProfilePreference("printing.print_preview_sticky_settings.appState", "{\"version\":2,\"isGcpPromoDismissed\":false,\"selectedDestinationId\":\"Save as PDF\"");
  chrome = new ChromeDriver(dir, o);</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can anyone tell me how I set the printer to PDF from the actual printer?</p>