How can we know whether the print job print the page successfully or not(on printer).......?

try
        {
            

            boolean complete = txtAfvoer.print(null, null, true, null, null, true);
            
            if (complete)
            {//show a success message
                JOptionPane.showMessageDialog(new JFrame(), "Printing Page\n" + "Please click finish after printing", "Finished",JOptionPane.INFORMATION_MESSAGE);
                btnFinish.setEnabled(true);
            }
            else
            {//show a message indicating that printing was cancelled
                JOptionPane.showMessageDialog(new JFrame(), "User cancelled printing session", "Error 25: Cancelled",JOptionPane.ERROR_MESSAGE);
            }
        }
        catch (PrinterException pe)
        {// Printing failed, report to the user
            JOptionPane.showMessageDialog(new JFrame(), "Printing failed...WHAT DID YOU DO??", "Error 26: Failed",JOptionPane.ERROR_MESSAGE);
        }

hmm, your question is a bit unclear..should the user know it was printed or the program? I posted code for a try & catch in printing, read the messageDialogs to understand what happend where during the printing, hopes this helps.

regards krefie

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.