Is there a way to change default portrait preview to landscape in print framework?
I have tried below -
PrintAttributes attrib = new PrintAttributes.Builder()
.setMediaSize(PrintAttributes.MediaSize.NA_LETTER.asLandscape())
.setMinMargins(PrintAttributes.Margins.NO_MARGINS)
. build();
and also tried below -
PrintAttributes attrib = new PrintAttributes.Builder()
.setMediaSize(PrintAttributes.MediaSize.UNKNOWN_LANDSCAPE)
.setMinMargins(PrintAttributes.Margins.NO_MARGINS)
. build();
I've noticed that it doesn't change the page orientation to Landscape
In above print setting dialog if I do change the orientation to landscape then and only then the print preview page changes orientation to Landscape. Can this be done programmatically? I want default preview in Landscape.
Find your printer in the Devices and Printers window and right-click the icon with your mouse. In the menu that appears, select Printing Preferences and find the option for Orientation in the preferences window. Change the option to Landscape to set the printer to Landscape mode as a default.
Program Settings Although the printer might be correctly configured to print in Portrait mode, the program itself might be configured to print in Landscape mode. These settings are typically adjusted by locating a Page Setup or Page Layout menu and then looking for Orientation.
I used below Code:
PrintManager printManager = (PrintManager) this.getSystemService(Context.PRINT_SERVICE);
String jobName = this.getString(R.string.app_name) + " Document";
PrintAttributes attrib = new PrintAttributes.Builder()
.setMediaSize(PrintAttributes.MediaSize.UNKNOWN_LANDSCAPE)
. build();
printManager.print(jobName, pda, attrib);
My Result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With