title: Android Print Dialog Options
body: <p>I have been trying to preset android print dialog options to user defined settings. But no matter what options i provide to printAttributes, I get only ISO_A4 page size as default in dialog.</p>
  
  <p>Following is the code i have been using:</p>
  
  <pre><code>if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {
  
               int pageTypeValue = Integer.parseInt(mSettingsPreferences.getString(Utility.SETTINGS_PDF_SIZE_TYPE, "4"));
  
              PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
              String jobName = getString(R.string.app_name) + " Document";
  
              PrintAttributes.Builder builder = new PrintAttributes.Builder();
              builder.setMediaSize(getSelectedMediaSize(pageTypeValue));
  
  
              printManager.print(jobName, new MyPrintAdapter("name_of_file", mFile, FinalPrescriptionActivity.this), builder.build());
  </code></pre>
  
  <p><strong>where getSelectedMediaSize(int value) returns MediaSize:</strong></p>
  
  <pre><code>public PrintAttributes.MediaSize getSelectedMediaSize(int pageType) {
  
      switch (pageType) {
          case (0):
              return PrintAttributes.MediaSize.ISO_A0;
          case 1:
              return PrintAttributes.MediaSize.ISO_A1;
          case 2:
              return PrintAttributes.MediaSize.ISO_A2;
          case 3:
              return PrintAttributes.MediaSize.ISO_A3;
          case 4:
              return PrintAttributes.MediaSize.ISO_A4;
          case 5:
              return PrintAttributes.MediaSize.ISO_A5;
          case 6:
              return PrintAttributes.MediaSize.ISO_A6;
          case 7:
              return PrintAttributes.MediaSize.ISO_A7;
          case 8:
              return PrintAttributes.MediaSize.ISO_A8;
          case 9:
              return PrintAttributes.MediaSize.NA_LETTER;
          case 10:
              return PrintAttributes.MediaSize.NA_INDEX_3X5;
  
          }
      return  null;
      }
  </code></pre>
  
  <p>Can someone please help me to set android print dialog options?</p>
  
  <p><a href="https://i.stack.imgur.com/r5Lie.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r5Lie.png" alt="enter image description here"></a></p>