Bom dia!
Fiz esta classe para imprimir PDF diretamente, está funcionando, mas é o seguinte:
Está imprimindo muito pequeno, preciso que imprima no tamanho de um papel A4, como faço isso?
public class print{
@SuppressWarnings("static-access")
public void imprimir(String fileName) throws FileNotFoundException, IOException, org.jpedal.exception.PdfException
{
try {
File f = new File(fileName);
FileInputStream fis = new FileInputStream(f);
FileChannel fc = fis.getChannel();
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
// Create PDF Print Page
PDFFile pdfFile = new PDFFile(bb);
PDFPrintPage page = new PDFPrintPage(pdfFile);
// Create Print Job
PrinterJob pjob = PrinterJob.getPrinterJob();
PageFormat pagerformat = PrinterJob.getPrinterJob().defaultPage();
pjob.setJobName(f.getName());
Book book = new Book();
book.append(page, pagerformat, pdfFile.getNumPages());
pjob.setPageable(book);
pjob.print();
} catch (PrinterException ex) {
Exceptions.printStackTrace(ex);
}
}
}