I'm trying to implement the print api, which more or less works. I can send a file to the Google Cloud Print app and print it, using the printing framework introduced in api level 19. But it would be nice if i wouldn't allways have to send the paperformat by hand, because it starts at the paperformat Index Card 4x6, which is not what i want, i want A4. If the GCP app would remember the configuration i would probably live with it, but i have to set it every single printjob, which is kinda frustating.
I've found that i shoudl be able to archieve this by setting the PrintAttributes. But no matter what i set them to, it is allways the paper format Index Card 4x6. If i set the format to A4 by hand in the printing dialog, it works just fine
PrintManager printManager = (PrintManager) ctx.getSystemService(Context.PRINT_SERVICE);
String jobName = "Jobname";
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMediaSize(PrintAttributes.MediaSize.ISO_A4);
builder.setColorMode(PrintAttributes.COLOR_MODE_MONOCHROME);
PrintAttributes attr = builder.build();
printManager.print(jobName, new PrintDocumentAdapterForFiles(ctx, new File(filePath), jobName), attr );
In case it matters: The printer is a Canon Pixma IP 110