4
So, I need to print a PDF directly to the printer, because I need to print Tax Notes.If I use this form Desktop d = Desktop.getDesktop().print("Caminho do arquivo")
it prints normally the first time, but opens the adobe together and the adobe closes the document and then when I will print again, it "Buga" and prints everything that is in the extremely small PDF. And the idea is to print directly and in the correct size of the paper.
I own these 3 printers :Bematech MP 4200 TH, Bematech MP 4000 TH e MP2500TH.
Below is how I learned to print directly from the printer.
PrintService iPadrao = PrintServiceLookup.lookupDefaultPrintService();
DocFlavor docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
try {
FileInputStream stream = new FileInputStream("C:\\Users\\EX-PHP\\Documents\\TestePDF2\\vai.pdf");
Doc doc = new SimpleDoc(stream, docFlavor, null);
DocPrintJob p = iPadrao.createPrintJob();
p.print(doc, null);
} catch (PrintException e) {
e.printStackTrace();
}
The PDF in question contains a tax note containing a QR code. I also tried with Pdfrenderer, and with some codes I found on the internet but without success,.
If you use
DocFlavor.INPUT_STREAM.PDF
, what happens?– Victor Stafusa
So there was just a mistake of my own, but putting everything right and with Flavor PDF it from invalid Browse. I need you to print it directly because it’s for printing a receipt.
– TheJ
Which model of your printer?
– Sorack
I have 2, Bematech MP 4200 TH, Bematech MP 4000 TH.
– TheJ