hey a very good day to all of the people on stackoverflow.
I am currently making a POS for a restaurant and I have completed everything. Now its come down to the printing process and I have done the coding which is working perfectly. Here's the coding for printing
jTable100.setModel(jTable1.getModel());
try {
String printerNameDesired = "Microsoft Print to PDF";
PrintService[] service = PrinterJob.lookupPrintServices(); // list of printers
DocPrintJob docPrintJob = null;
int count = service.length;
for (int i = 0; i < count; i++) {
if (service[i].getName().equalsIgnoreCase(printerNameDesired)) {
docPrintJob = service[i].createPrintJob();
i = count;
}
}
PrinterJob pjob = PrinterJob.getPrinterJob();
pjob.setPrintable(this);
pjob.setPrintService(docPrintJob.getPrintService());
pjob.setJobName("job");
pjob.print();
} catch (PrinterException ex) {
Logger.getLogger(DineInPrintDialogBox.class.getName()).log(Level.SEVERE, null, ex);
}
The output is PrintOut Image
Now there's a problem that as you can see in the picture that the table is scrollable and not able to print all the details. so I want is that whenever the table has more then 5 item, like for example 12, I want that it may print the first 5 on the first page, then on the second page and 2 on the last page.
how can I achieve this?
and my second problem is how can I adjust the size of the jframe according to the printer page size. like how can the printer tell the java program that the page size is whatever it supports. for example the printer supports a1 size. How can the printer tell the program that the size of the page is a1 and it should properly fit.
Thanks in advance and hope things are fine with everyone on StackOverflow.