printing - Java print, Letter format instead of A4 -


as far know, java print uses os (windows) settings (format type) when sending task printer. however, no matter how change code , despite fact settings set a4, after sending task printer accepts task letter format , printer out of paper error. although, when press restart printing button on printer prints out file correctly. have tried lot of different methods stackoverflow didn't work out. tried application on pc connected same model of printer - same problem. maybe i'm missing small or looking solution in wrong place?

this piece of code:

private printerjob createpdfprinterjob(pddocument pdfdocument) {      printerjob printjob = printerjob.getprinterjob();      pageformat pageformat = new pageformat();     pageformat.setorientation(pageformat.portrait);      paper paper = new paper();     pageformat.setpaper(paper);      try {         printjob.setprintable(new pdpageable(pdfdocument), pageformat);     }     catch(printerexception ex) {         ex.printstacktrace();     }      return printjob; } 

so, did quick test using:

paper paper = new paper(); 

which generates page of 21.59x27.94 cms, consistent letter

i had at:

printerjob.getprinterjob().defaultpage().getpaper() 

which generates page of 21x29.7 cms, consistent a4.

so, recommendation use printerjob's default pageformat bases of work


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -