Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    5
    Rep Power
    0

    Default IllegalArgumentException: Bad margins When Printing to a DYMO LabelWriter 450

    Hello forum, I would be grateful for any suggestions on the following.

    I am attempting to print text (or a circle) to a DYMO LabelWriter 450. The code below works find if I am printing to a standard A4 printer. I can also print from Notepad to the LabelWriter. However, when I try and print to the LabelWriter with the following code, I get a "Bad Margins" error. I have also set the correct paper (label) size in the printer properties...

    Java FX Code:
    Printer printer = Printer.getDefaultPrinter();
    System.out.printf("Selected: %s\n", printer.getName());
    			
    Node node = new Circle(2,2,2);  //something to print
    try {
    
       PrinterAttributes attributes = printer.getPrinterAttributes();
       System.out.printf("\nLabel Size: %g, %g(%s)\n", attributes.getDefaultPaper().getWidth(), attributes.getDefaultPaper().getHeight(), attributes.getDefaultPaper().toString());
    				
       Paper label = attributes.getDefaultPaper();
       PageOrientation orientation = printer.getPrinterAttributes().getDefaultPageOrientation();
       PageLayout layout = printer.createPageLayout(label, orientation, MarginType.HARDWARE_MINIMUM);
       System.out.printf("\nPageLayout: %s\n", layout.toString());
    
       PrinterJob printerJob = PrinterJob.createPrinterJob();
    				
       boolean success = printerJob.printPage(layout, node);
       System.out.println("printerJob.printPage : " + success);
    
       if(success) {
          printerJob.endJob();
       }
    } catch(IllegalArgumentException e) {
       e.printStackTrace();
    }
    The output:

    Java FX Code:
    Selected: DYMO LabelWriter 450
    
    Label Size: 54.0000, 144.000(Paper: 11355 Multi-Purpose size=19.0x50.8 MM)
    
    PageLayout: Paper=Paper: 11355 Multi-Purpose size=19.0x50.8 MM Orient=PORTRAIT leftMargin=4.079055190086365 rightMargin=2.8799983263015747 topMargin=16.319055318832397 bottomMargin=4.319998025894165
    java.lang.IllegalArgumentException: Bad margins
    Any help, pointer and or suggestion will be gratefully revived...

    Kind Regards,
    Harold Clements

  2. #2
    jimb0p is offline Member
    Join Date
    Dec 2016
    Posts
    1
    Rep Power
    0

    Default Re: IllegalArgumentException: Bad margins When Printing to a DYMO LabelWriter 450

    did you solve the problem? I'm having exactly the same problem.

Similar Threads

  1. Replies: 0
    Last Post: 01-10-2014, 06:55 AM
  2. problem displaying print margins in dialog
    By simo_mon in forum Java 2D
    Replies: 2
    Last Post: 04-19-2012, 02:54 AM
  3. Set page margins when printing in java
    By simplegoogly in forum AWT / Swing
    Replies: 4
    Last Post: 04-14-2011, 07:09 PM
  4. Problem with margins/spacing
    By joseche in forum AWT / Swing
    Replies: 2
    Last Post: 12-26-2008, 08:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •