Reputation: 133
Using this PrinterJob i would like to print the pdf file where we dont want user to select the format of printing and filename. I mean that the file name and path will be given from code as that file is to be reused. Currently my code is
PrinterJob pJob = PrinterJob.getPrinterJob();
Paper paper = new Paper();
PageFormat pageFormat = new PageFormat();
pageFormat.setPaper(paper);
printJob.setPrintable(this, pageFormat);
if (printJob.printDialog() == false)
{
return false;
}
try
{
preparePrintJob(); // This method will create all header,detail and footer
printJob.print();
}
catch (Exception e)
{
}
This is just a sample code where there is no issue in printing but my requirement is to not to show dialog for which i will remove the printJob.printDialog() line and then how can i set the filepath and filename? Also the format of file should be pdf as the saved file is to be fetched and reused
Upvotes: 0
Views: 973
Reputation: 1049
Use method print(PrintRequestAttributeSet attributes). So You can manually set all required attributes.
Upvotes: 0