3

I am developing a POS application for my company, and I have to print to a receipt printer. Printer model Epson Thermal printer paper width 80 mm. My java thermal printer code not able to print long receipt(more than A4 sheet size). Its work fine normally, but in case where there is paper size more than A4 in pdf file then it generate half print. My code is under mentioned

PrinterJob job = PrinterJob.getPrinterJob();
PDDocument document = null;
    try {
        document = PDDocument.load(temp);

        for (int i=0;i<document.getNumberOfPages();i++) {
            PDDocument doc = new PDDocument();
            doc.addPage(document.getPage(i));
            job.setPageable(new PDFPageable(doc));
            job.print();
            doc.close();
        }


        document.close();

Obs: temp is a temporary file in format PDF. I try define page but is not working

Paper paper = new Paper();
paper.setSize(paper.getWidth(), paper.getHeight());

I also try define MediaPrintableArea but is not working because resets text to fit in A4 does not reset the paper size.

Thanks to anyone who can help

JMTA
  • 31
  • 3
  • Have you tried `setImageableArea()`? See at the end of https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/printing/Printing.java?view=markup . Make sure you're using the latest version (2.0.7). (Sadly, there have often been reports of trouble with receipt printers, so I don't know if this will help) – Tilman Hausherr Nov 01 '17 at 13:18
  • Thank you for response. Unfortunately this does not work because I have already tested it. Are you aware of any solution with another library, for example. what interests me is that it is printed on paper larger than A4, the method is indifferent – JMTA Nov 01 '17 at 22:18
  • Don't know; other java products are jpedal and icepdf. Btw you're assigning the current paper size as new paper size - weird. – Tilman Hausherr Nov 01 '17 at 22:42

0 Answers0