So i followed VGR's advice and i got it working. This was my final code, in case anyone runs into the same problem:
Date data = new Date(); //Data
DateFormat dataform = new SimpleDateFormat("dd-MM-yyyy"); //Data
PrintService service=getPrinterService("Microsoft XPS Document Writer");
if(service!=null){
try{
File outputFile = new File(dataform.format(data)+"-Recibo"+nmrRec+".xps");
Doc doc = new SimpleDoc(new myReceipt(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(new Destination(outputFile.toURI()));
DocPrintJob job = service.createPrintJob();
job.print(doc, attributes);
} catch(Exception e){
System.out.println("kaboom"+e);
}
}
else{
System.out.println("XPS Printer not found");
}
And there's my receipt class:
class myReceipt implements Printable{
@Override
public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
String temp;
if (page > 0) { /* We have only one page, and 'page' is zero-based */
return NO_SUCH_PAGE;
}
/* User (0,0) is typically outside the imageable area, so we must
* translate by the X and Y values in the PageFormat to avoid clipping
*/
Graphics2D g2d = (Graphics2D)g;
g2d.translate(pf.getImageableX(), pf.getImageableY());
int lineSize=20;
Font testFont=new Font("Lucida Console", Font.BOLD, 20);
// font name, style (0 for Plain), font size
g.setFont(testFont);
int line=20;
g.drawString(" Fatura/Recibo nº"+nmrRec+" ", 5, line);
return PAGE_EXISTS;
}
}