user8070573
user8070573

Reputation: 31

PrintAttributes not working. not able to create custom page size

I am struggling with google printing interface in tablet. I want a print of fixed page size. PrintAttributes.Builder is not modifying the page and margin settings. How can i create a new custom/fixed page dimension for print. Now It shows ISO_A4 by default for HP printer.

My code is below:

PrintAttributes.Builder builder = new PrintAttributes.Builder();
PrintAttributes.MediaSize custom = new PrintAttributes.MediaSize("VISIT_K" , "VISIT_K", 86000,139860);
custom.asPortrait();
builder.setMediaSize( custom );
printJob = printManager.print(jobName, adapter,
builder.build());

Upvotes: 3

Views: 1832

Answers (1)

Nonos
Nonos

Reputation: 2518

Which Android version are you testing on? See this answer concerning a bug pre- Android 7 Regardless, the attributes here serve only as "hints", from the Android documentation:

You can use this parameter to provide hints to the printing framework and pre-set options based on the previous printing cycle, thereby improving the user experience. You may also use this parameter to set options that are more appropriate to the content being printed, such as setting the orientation to landscape when printing a photo that is in that orientation.

I think if it conflicts with what the printer is reporting as supported/default, the printer's attributes may take precedence. This could be a feature/bug report to Android if it is not otherwise working.

Upvotes: 1

Related Questions