0
我一直在嘗試預設android打印對話框選項到用戶定義的設置。但是不管我給printAttributes提供什麼選項,我只在對話框中獲得ISO_A4頁面大小。安卓打印對話框選項
以下是代碼我一直在使用:
if (Build.VERSION.SDK_INT >= 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());
其中getSelectedMediaSize(int值)返回的MediaSize:
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;
}
能有人幫我設置的android打印對話框中的選項?
請參考下面我的回答,讓我知道,如果它幫助您的代碼應工作 – Nonos