Help Please - Landscape Printing in JDK1.3

Iam trying to print a line of text of 160 chars wide in landscape
format. The ImageableWidth and ImageableHeight are 792 and 612
respectively. The ImageableX and ImageableY are both 72(1 inch).
Font -> ("Courier", Font.PLAIN, 7),
noOfChars/line -> 162 for the Imageable area 792 x 612
But after printing I could see the line starting after 2 inches
as Right Margin, because of which, I'm not able to print the
complete 160 char line.
I set the value posX=0 to start after 1 inch, but still the printing
starts only after 2 inches but initial few chars are eaten.
when posX = 72
<- 2" R Margin ->0123456789 0123456789 .... 154th char
when posX = 0
<- 2" R Margin ->56789 0123456789 ....... 160th char
please help.
lenin.
import java.util.*;
import java.awt.*;
import java.awt.print.*;
public class Printer implements Printable {
     public int print(Graphics g, PageFormat format, int pageIndex) {
     String content = "0123456789 0123456789 0123456789 " +
          "0123456789 0123456789 0123456789 " +
          "0123456789 0123456789 0123456789 " +
          "0123456789 0123456789 0123456789 " +
          "0123456789 0123456789 0123456789 012345";
     int totalWidth = (int) format.getImageableWidth();
     int totalHeight = (int) format.getImageableHeight();
     System.out.println("ImageableWidth : " + totalWidth);
     System.out.println("ImageableHeight : " + totalHeight);
     int posX = (int) (format.getImageableX());
     int posY = (int) (format.getImageableY());
     posY += 20;
     System.out.println("PosX : " + posX);
     System.out.println("PosY : " + posY);          
     pageIndex++;
     FontMetrics fontMetrics =
g.getFontMetrics(new Font("Courier", Font.PLAIN, 7));
     int charWidth = fontMetrics.stringWidth("W");
     int charHeight = fontMetrics.getHeight() + 1;
     int noOfLines = Math.round(totalHeight / charHeight);
     int noOfCharsPerLine = Math.round(totalWidth / charWidth);
     System.out.println("No Of Lines : " + noOfLines);
     System.out.println("No Of Char/Line : " + noOfCharsPerLine);
     if (pageIndex > 0) {
     g.setFont(new Font("Courier", Font.PLAIN, 7));
     g.drawString(content, posX, posY);
     return 0;          
     public static void main(String args[]) {
          Printer myPrinter = new Printer();
          PrinterJob job = PrinterJob.getPrinterJob();
          PageFormat pageFormat = job.defaultPage();
          pageFormat.setOrientation(PageFormat.LANDSCAPE);
          Book book = new Book();          
          book.append(myPrinter,pageFormat);          
          job.setPageable(book);
          if (job.printDialog()) {
               try {
                    job.print();
               catch (Exception e) {
                    e.printStackTrace();
          System.exit(0);

Hi,
I'm developing a report program with java and I want to print this report.
These are my page settings:
paper.setSize(594.936, 841.536);
paper.setImageableArea(0,0,594.936, 841.536)
and my print method includes :
Graphics2D g2d = (Graphics2D) g;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
but I can't use the page effectively. I have 28 mm blank from the left and 13 mm blank from the right.
I can't write anything this blank sections. It looks as if it was deleted.
What should I do?
Thank you very much for your help.

Similar Messages

  • Help please - when printing to adobe pdf, this hangs and stays in spool status

    Can someone help assist and troubleshoot this problem I'm facing with printing to pdf.
    The background is I provided a vendor a Word converted PDF document approval letter to upload into the system.  While UAT testing, we are not able to print to PDF - hangs in print spool.
    However the document checklist that had been uploaded into the system, properly prints to pdf (see page 2 attached).  Is there any way to debug or determine the root cause since the vendor believes that they have delivered a product that works from their perspective and suggest it's an Adobe issue.

    Hi,
    Could you please provide both the word documents(one that prints and the other that does not print) ? This would be helpful in isolating the issue.
    Thanks,
    Swati
    [email protected]

  • Help please with printer constantly cleaning heads and when prints there is nothing on the page

    Hello,
    I have an Officejet Pro 8000 series (not wireless). Everytime I turn it on to use it it starts clearning the printer heads or something like that and never stops. I have tried holding the x for 3 seconds then holding down the on button and pressing the ethernet button and x again but it won't print a test page or anthing.
    Please can you advise.
    Many thanks
    Tania

    Hi @tpf40 
    I understand your printer is is performing a printhead cleaning every time you turn it on, and when you print, it is printing blank pages. Please use the following document to troubleshoot the issue; Troubleshooting Print Quality Issues.
    I hope this helps.
    Please click the Thumbs up icon below to thank me for responding.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Sunshyn2005 - I work on behalf of HP

  • Help please with printing?

    I am having difficulty printing from adobe x. I keep getting error messages...acrod32.exe. Help?

    what's the full error message? Maybe your printer is not configured right?

  • My iPad shows a message "Cannot find AirPrint printer". I used to use my iPad to print materials using HP wireless printer D110. Now it does not want to print. Is this because I am now using IOS 7? What should I do to solve the problem? Help please.

    My iPad shows a message "Cannot find AirPrint printer". I used to use my iPad to print materials using HP wireless printer D110. Now it does not want to print. Is this because I am now using IOS 7? What should I do to solve the problem? Help please.

    Restart your WiFi router and printer by removing power for 30 seconds.

  • My iphone 4S will not find my printer for printing from my iphone why can anyone help please

    My I phone 4s is switched on to e print but cannot find tany air printers on any Apple devices that I have

    Hey tomohawk122,
    Have any of the Apple devices worked before?  I'll post a few questions, and a document you can try, please let me know how it goes
    1. Have you had a chance to try steps like power resetting the router and the apple devices?
    2. how far away is the router from your ipad usually?
    3. which printer do you have?
    Please try the steps in this doc, under "no airprinters found" http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&dlc=en&docname=c02623193&jumpid=reg_r1002_usen&lc=...
    Cheers,
    *** If my reply was helpful, please click on the "Kudos Thumbs-Up" on the right, as a way to say "Thanks!".
    If this reply also fixed your issue - please click the "Accept as Solution" button, so that others can find the same answer. ***

  • Just updated the latest Epson software printer update from Apple. Now all my prints look solarized. How do I get rid of the new update and go back to the perfect prints I had before? Help please.

    Just updated the latest Epson software printer update from Apple. Now all my prints look solarized. How do I get rid of the new update and go back to the perfect prints I had before? Help please. Wasting ink and paper at the moment!!!!!!
    I have tried the printer with my laptop (not updated) and everything is fine. It's just the beautiful 27" Imac that can no longer print.

    Might be a corrupted printer preference file ...
    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Type this exactly as you see it here:
    ~/Library/Preferences
    Click Go
    Move the com.apple.PrinterPrefs.plist file from the Preferences folder to the Trash.
    Restart your Mac, restart the printer...

  • On my HP printer Officejet4620 I get an error message "waiting for printer to become available".  Help please?

    On my HP printer Officejet4620 I get an error message "waiting for printer to become available".  Help please?

    Restart the computer and restart the printer. If you continue to have the problem the follow the steps Apple outlines in Reset Printing System feature article.

  • HP Photosmart Premium c309g-m does not have a mirror image print option-help please

    After twice being dropped from HP chat support I have laned in this forum to get some help please.
    I need to be able to print mirror images from my printer and it simply is not a option-it's not a matter of turning on the
    option, it is not there at all.
    Thanks
    Donna

    Check the iron-on packaging for ink specs.   Make sure to use HP iron-on paper.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • TS4212 can anyone help please..  since iCloud  came on the scene  My all in one printer  keeps saying  it is not USB connected.  I have been  looking for over a week now   and even chatted  with the USA  but cannot get it to work

    can anyone help please..  since iCloud  came on the scene  My all in one printer  keeps saying  it is not USB connected.   what do I do
    I have been  looking for over a week now   and even chatted  with the USA  but cannot get it to work.
    I am really struggling

    Thanks
    someone named  Eloisa   she gave me   a phone no.   or visit hp.com/uk
    cannot make head nor tale of it all.  I am old.  and find everything hard to undertstand

  • DEP Print Crash (Reader 9.3.2) - Help please?

    Help please anyone?
    Window DEP (Deta Execution Protection) stops me printing pdfs and the print crashes.
    If I tick/check DEP to allow me to use Reader 9 that makes NO difference even though it says if should.
    I'm using Reader 9.3.2 - not an earlier version - and the print crash happens either in Reader, using it alone, or when I open a pdf in IE or Firefox.
    I am running XP SP3, recently updated from SP2   (there maybe a connecton - was it the XP3 update which did it?)
    This is very frustrating. I don't want to abandon Adobe Reader and use a different company's  program but I have wasted hours so far tring to find a fix for this.
    Incidentally fiddling with Javascript [Reader>Edit>Preferences>Untick Enable Acrobat JavaScript] which is one recommended fix whichdoesn't work.
    Maybe there any other files I can get DEP to ignore? (NB they all have to be .exe files so be sure to tell me where to find them!)
    All advice gratefully received. I am SOooo fed up with this.
    Thanks!

    All I know is that I can't print from Adobe Reader any more but I can print pdfs since I replaced it with Foxit Reader.
    I suspect this is maybe connected with my XP upgrade from SP2 to SP3.
    I knew it might mess things up and this happened soon after. I also can't print AT ALL from Firefox now and that happened at the same time too.
    Microsoft again....? Who knows. I have solved my pdf printing problem a roundabout way, but not my Firefox problem - tho that isn't for this forum!

  • I'm trying to setup a printer go wireless through my airport extreme, but every time I try to print the printing file gets paused. I'm in loop. PLEASE HELP! (The printer is a Brother 7020  monochrome)

    I'm trying to setup a printer go wireless through my airport extreme, but every time I try to print the printing file gets paused. I'm in loop. PLEASE HELP! (The printer is a Brother 7020  monochrome)

    I had the exact same problem
    It turns out I was using a 20 foot USB cable between the printer and the Airport Extreme and the signal had become to weak to work. Try using nothing more than a 6 foot cable or try a new cable

  • I'm using windows 7 and working in office 2010. I have installed iCloud and I can't print my calendar from outlook all it will print is a blank calendar no appointments or birthdays . can anyone help please.

    I’m using windows 7 and working in office 2010. I have installed iCloud and I can’t print my calendar from outlook all it will print is a blank calendar no appointments or birthdays . can anyone help please.
    Geoff

    I had a similiar problem, with my multiple devices.  I open iTunes and when all devices were connected I went to the info section on each device.  Under info I checked the sync calandars. Under that I click all calanders. I then did the apply in low right. I then did the sync function and it fixed it for me.  You have to do this for each device.
    I also checked the device (ipad,Iphone) themselves and change the calander selection to NO Catagory.  Hope this helps.

  • Please help me in Printing a text file :-(

    Hi,
    I have asked this question 3 times, but I didnt get any reply. Can someone please help me in printing a text file to a printer using java. I am able to print it but the problem is the whole file is printed in a messy way. Is there any method in java that prints the text file exactly how it is?
    Thank u very much.

    JavaWorld has a series of articles on how to print using Java: http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html

  • Help please can only print grey

    i am using a canon bjc80 which when i test print it prints all colours and black
    but when i print from pages or even word every thing is printed in grey i cannot find what i am doing wrong any help please
    thanks in advance

    You didn't say, so I'll ask - have you looked at all the options in the Copies & Pages pull-down menu?

Maybe you are looking for