Results 1 to 6 of 6
  1. #1
    justlynn is offline Member
    Join Date
    Jun 2010
    Posts
    18
    Rep Power
    0

    Default Printing problem

    im using printing to primoPDF,
    im using pageFormat.setOrientation(PageFormat.LANDSCAPE);
    but after i get the PDF file it still show at portrait orientation
    anyone can help me??

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    justlynn is offline Member
    Join Date
    Jun 2010
    Posts
    18
    Rep Power
    0

    Default

    try
    {
    JFrame frame = new JFrame("Print");
    PrintJob printer = getToolkit().getPrintJob(frame, "Payment Receipt", null);
    PageFormat pageFormat = new PageFormat();
    pageFormat.setOrientation(PageFormat.LANDSCAPE);

    if (printer != null)
    {
    Graphics grPrintPage = printer.getGraphics();

    grPrintPage.drawString("Computer ID",60, 60 );


    grPrintPage.dispose();
    printer.end();
    }

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Try to alter the default page.

    Java Code:
        PrinterJob objJob = PrinterJob.getPrinterJob();
    
        PageFormat pf = objJob.defaultPage();
        pf.setOrientation(PageFormat.LANDSCAPE);

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    Yep.
    All you're doing is creating a PageFormat object that you don't actually use with the PrintJob.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Yeah, I guess that OP will test it. If read more on the API could easily find.

    @OP, and also please use code tags when you posting again. Unformatted codes are really hard to read. If you don't know how to do it, check on my forum signature.

Similar Threads

  1. Problem printing an array
    By denial in forum New To Java
    Replies: 3
    Last Post: 11-01-2009, 10:09 PM
  2. Printing only one page problem
    By AndreiDMS in forum Java 2D
    Replies: 0
    Last Post: 10-09-2009, 03:03 AM
  3. Problem in printing JTable values
    By shanssat in forum AWT / Swing
    Replies: 3
    Last Post: 02-04-2009, 08:15 AM
  4. Problem after Printing GUI.
    By coldblood22 in forum AWT / Swing
    Replies: 1
    Last Post: 04-05-2008, 02:43 PM
  5. printing problem
    By ntpl in forum AWT / Swing
    Replies: 0
    Last Post: 11-27-2007, 11:20 AM

Posting Permissions

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