This discussion is archived
1 2 Previous Next 16 Replies Latest reply: Jun 6, 2013 12:40 PM by 1013319 RSS

Problem with printing to Lexmark int java 7

makbolat Newbie
Currently Being Moderated
I have a problem in printing to Lexmark dot matrix printer... It working properly at java 6 but trying to print at java 7; the characters are overlapping to next character.

[url https://plus.google.com/u/0/photos/115971918949425232841/albums/5795049509502288417/5795049510472822418]Here is a picture of printed document.
Thank you for help.

Edited by: user1060316 on 03.Eki.2012 04:53

Edited by: user1060316 on 05.Eki.2012 01:11 -- Url changed
  • 1. Re: Problem with printing to Lexmark int java 7
    sabre150 Expert
    Currently Being Moderated
    Sorry to hear of your problem but how are we supposed to help diagnose the problem without knowing exactly how you are communicating with the printer and what platform you are working on?
  • 2. Re: Problem with printing to Lexmark int java 7
    makbolat Newbie
    Currently Being Moderated
    I tried this program on windows xp sp2 on 32 bit pc. And the pc that I am using with this properties: w
    windows 7 enterprise SP 1 64 Bit OS.

    The printer model is Lexmark Forms Printer 2580 and one more Lexmark model that my clients are using that I don't remember the model...

    On the other side PSON LQ-590 ESC/P 2 Ver 2.0 and SHARP AR-M276 PCL6_T1 are the other printers that working properly...

    Here is my printing class:
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import java.awt.print.Book;
    import java.awt.print.PageFormat;
    import java.awt.print.Paper;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    
    public class DirectPrint implements Printable {
    
         public void print() throws PrinterException {
              PrinterJob pPrinterJob = PrinterJob.getPrinterJob();
              pPrinterJob.setPrintable(this);
    
              // if (pPrinterJob.printDialog()) {
              PageFormat pPageFormat = pPrinterJob.defaultPage();
              Paper pPaper = pPageFormat.getPaper();
    
              pPaper.setImageableArea(0.0, 0.0, pPaper.getWidth(), pPaper.getHeight());
              pPageFormat.setPaper(pPaper);
              // pPageFormat = pPrinterJob.pageDialog(pPageFormat);
              Book pBook = new Book();
              pBook.append(this, pPageFormat);
              pPrinterJob.setPageable(pBook);
              pPrinterJob.print();
              // }
         }
    
         @Override
         public int print(Graphics g, PageFormat aPageFormat, int aPageIndex) {
    
              if (aPageIndex > 0) {
                   return NO_SUCH_PAGE;
              }
    
              Graphics2D g2d = (Graphics2D) g;
              AffineTransform pOrigTransform = g2d.getTransform();
              try {
    
                   g2d.translate((int) aPageFormat.getImageableX(),
                             (int) aPageFormat.getImageableY());
                   aracFisiYazdir(g2d);
              } catch (Exception e) {
                   e.printStackTrace();
              }
    
              g2d.setTransform(pOrigTransform);
              return PAGE_EXISTS;
         }
    
         private void aracFisiYazdir(Graphics g) {
              Font tFont = new Font("Trebuchet MS", Font.PLAIN, 10);
              g.setFont(tFont);
              g.drawString("Güvenlik Sicil No: 452154", 390, 80);
              g.drawString("TEST TEST", 210, 105);
              g.drawString("01 DF 4521", 210, 130);
              g.drawString("01/01/2012", 210, 200);
    
         }     
    
         public static void main(String[] args) {
    
              DirectPrint p = new DirectPrint();
              try {
                   p.print();
              } catch (PrinterException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              }
    
         }
    
    }
    Edited by: sabre150 on Oct 3, 2012 11:24 PM

    Moderator action : added [ code] tags to format the code.

    Edited by: user1060316 on 03.Eki.2012 21:50

    Edited by: user1060316 on 03.Eki.2012 21:51

    Edited by: user1060316 on 04.Eki.2012 01:04
  • 3. Re: Problem with printing to Lexmark int java 7
    EJP Guru
    Currently Being Moderated
    Moderator action: Moved this to 'New to Java'. The connection with the Concurrency forum escapes me.
  • 4. Re: Problem with printing to Lexmark int java 7
    Tolls Journeyer
    Currently Being Moderated
    What happens with, say, a Word document using that font from each machine?

    Or put another way, I'm not convinced this is a Java problem.
  • 5. Re: Problem with printing to Lexmark int java 7
    makbolat Newbie
    Currently Being Moderated
    Hi Tolls,

    There is no problem when printing a word document, I changed the fonts and tried all fonts that lexmark printer supported... I tried to change the printer modes, IBM and EPSON but nothing changed. When I change the jre from java 7 to java 6 it works fine. Than changing to java 7 than same thing happens. I think there is a bug in Java 7....

    Edited by: user1060316 on 04.Eki.2012 06:46
  • 6. Re: Problem with printing to Lexmark int java 7
    sabre150 Expert
    Currently Being Moderated
    And what happens if you use a non-MS font in your test?
  • 7. Re: Problem with printing to Lexmark int java 7
    makbolat Newbie
    Currently Being Moderated
    I changed the print routine like following, than run it on Java 6 and Java 7. I scanned the printout paper: [url https://plus.google.com/u/0/photos/115971918949425232841/albums/5795699595957827457/5795699599396438482#photos/115971918949425232841/albums/5795699595957827457/5795699599396438482]Click here to see printout paper.

    ..So, changing the font didn't solve the problem...


    Font tFont = new Font(null, Font.PLAIN, 10);
              g.setFont(tFont);
              g.drawString("Font: null, Size: 10", 0, 10);
    
              tFont = new Font("Arial", Font.PLAIN, 10);
              g.setFont(tFont);
              g.drawString("Font: Arial, Size: 10", 0, 25);
    
              tFont = new Font("Arial", Font.PLAIN, 8);
              g.setFont(tFont);
              g.drawString("Font: Arial, Size: 8", 0, 40);
    
              tFont = new Font("Courier", Font.PLAIN, 10);
              g.setFont(tFont);
              g.drawString("Font: Courier, Size: 10", 0, 55);
    
              tFont = new Font("Courier", Font.PLAIN, 8);
              g.setFont(tFont);
              g.drawString("Font: Courier, Size: 8", 0, 70);
    Edited by: user1060316 on 04.Eki.2012 23:01

    Edited by: user1060316 on 04.Eki.2012 23:02

    Edited by: user1060316 on 04.Eki.2012 23:26

    Edited by: user1060316 on 04.Eki.2012 23:27

    Edited by: user1060316 on 05.Eki.2012 01:07------- url changed

    Edited by: user1060316 on 05.Eki.2012 01:12
  • 8. Re: Problem with printing to Lexmark int java 7
    makbolat Newbie
    Currently Being Moderated
    Is there anybody to help me....
  • 9. Re: Problem with printing to Lexmark int java 7
    967751 Newbie
    Currently Being Moderated
    We are experiencing a similar issue in our application. Our code is a lot more complicated but it essentially writes the root pane of a JEditorPane to the graphics object as a way of printing HTML from within our application. In this context we are printing check endorsements to an Epson TM-H6000IV printer (I have tried a couple of different models of the same printer). Our receipts print the same under both Java 6 and 7, but the check endorsements do not. The receipts use thermal transfer, the slip/validation printer is an impact printer but both take almost the same path through the code for printing.

    Like your application, under Java 7 you can see the characters are not printing correctly. Most characters appear to be stretched to twice the normal width but they start in the normal position so the characters overlap and are unreadable. Using the exact same code to print to a laser printer it looks normal. Using the exact same code to print under Java 6 it looks normal. I have tried many different fonts and have tried lots of tweaks to the code but nothing has corrected the output.
  • 10. Re: Problem with printing to Lexmark int java 7
    967751 Newbie
    Currently Being Moderated
    We found a workaround. I don't know if it is a good one but it works. Basically we "printed" to a buffered image, then copied that buffered image to the printer. It isn't a good solution but it gets around the other problem.
  • 11. Re: Problem with printing to Lexmark int java 7
    gimbal2 Guru
    Currently Being Moderated
    I see mention of this being a bug, but did anyone report anything to the Java bug database? If you don't do anything, it won't get fixed.
  • 12. Re: Problem with printing to Lexmark int java 7
    makbolat Newbie
    Currently Being Moderated
    I just reported this as bug to the bug database.

    Edited by: user1060316 on 21.Kas.2012 07:03
  • 13. Re: Problem with printing to Lexmark int java 7
    ericC Newbie
    Currently Being Moderated
    I have exactly same issue when printing to a impact printer in latest jdk 1.7_17. Where did you report the bug? I would like to find out if it is going to be fixed anytime soon.

    Thanks.
  • 14. Re: Problem with printing to Lexmark int java 7
    1006321 Newbie
    Currently Being Moderated
    Hi, any update on this? It seems to be affecting latest Java 6 as well. It is not only for Lexmark printers. We have this when printing Japanese characters using the java.awt.print.PrinterJob if the String contains both Japanese characters and digits.
    I submitted a bug a while ago but don't have any ID. Can't find it in the bug database...
    Thanks for helping
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points