Need Printing Help (location to top-left?)

im able to print out a JFrame, no problem..but the onscreen image and whats printed on paper arent exactly the same
1) Printed is 1.5 - 2X bigger than onscreen (1280x1024 resolution)
2) Printed starts near the middle of the page, not at the top left hand corner
public class PrintUtilities implements Printable {
  private Component componentToBePrinted;
  public static void printComponent(Component c) {
    new PrintUtilities(c).print();
  public PrintUtilities(Component componentToBePrinted) {
    this.componentToBePrinted = componentToBePrinted;
  public void print() {
    PrinterJob printJob = PrinterJob.getPrinterJob();
    printJob.setPrintable(this);
    if (printJob.printDialog())
      try {
        printJob.print();
      } catch(PrinterException pe) {
        System.out.println("Error printing: " + pe);
  public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
    if (pageIndex > 0) {
      return(NO_SUCH_PAGE);
    } else {
      Graphics2D g2d = (Graphics2D)g;
      g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());   
      disableDoubleBuffering(componentToBePrinted);
      componentToBePrinted.paint(g2d);
      enableDoubleBuffering(componentToBePrinted);
      return(PAGE_EXISTS);
  /** The speed and quality of printing suffers dramatically if
   *  any of the containers have double buffering turned on.
   *  So this turns if off globally.
   *  @see enableDoubleBuffering
  public static void disableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(false);
  /** Re-enables double buffering globally. */
  public static void enableDoubleBuffering(Component c) {
    RepaintManager currentManager = RepaintManager.currentManager(c);
    currentManager.setDoubleBufferingEnabled(true);
}by simply calling PrintUtilities.print(myJFrame), it prints. how can i maka the onscreen and the printed page be "exact size" and how can i make it start printing from the top left hand corner?
thanks
i tried using myMainPanel.setLocation(0,0); in the gui construction...and also setting g2d.setFont(smallerFont); from PrintUtilities..but doesnt work at all
any ideas? thanks

You should change some piece of code ....Just change the part in :
public int print(Graphics g, PageFormat pageFormat, int pageIndex) {...}
function.
1) scale the graphics to see the whole screen on the page
/**copy this code before
* "componentToBePrinted.paint(g2d);"
*line
Dimension dimension=componentToBePrinted.getSize();
g2d.scale( 1.0*pageFormat.getWidth()/dimension.width,
1.0*pageFormat.getHeight()/dimension.height );
// "1.0*" is for casting to double2) delete the code line :
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());to start drawingfrom (0,0) coordinate

Similar Messages

  • My printer has started to print in only the top left quarter of the page. help

    My pixma MX310 printer has started to print the whole document in the upper left quarter of the page and i can't figure out what setting may need to be changed. in the print preview it shows the full page ready to print. i'm frustrated

    Hello wendolynsworld.
    It may be possible that the paper size is currently set to 4"x6" or 5"x7". 
    Before printing, please check the printer settings in the Print menu on your computer.  Make sure that the paper size is set to "Letter" or 8.5"x11".
    If you have any difficulties with finding the paper size setting, please tell us what version of Windows or Mac OSX is on your computer. 
    Also, tell us what programs are being used when this issue occurs.
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Need Printer help on my first Mac

    I have just purchased my first Mac, an 11" MBA. I have file sharing working wonderfull. At this point my problem is printer sharing. My main computer is a PC and is wired to the router and wired USB to my printer and prints fine. I have a second PC that is wireless to the router and prints wirelessly to the main PC. This PC prints fine as well. My MBA shares files fine with the other two PC's but won't print correctly. I go thru the print set up just fine and it shows the network workgroup, pc, and printer. I have downloaded the drivers for mac os 10.6 from the printer website. At this point when I press print, the job seems to get stuck in que on the mac as well as the PC. The PC print job shows 0 bytes and seems to get hung up.
    When I set up the printer it asks for a password for the print server or allows me to set it up as a guest. I have done guest, and used a password but have no idea if that password is correct.
    I have a cannon mp600 printer, and a ATT Uverse router (2wire) if that matters, can anyone help me get this thing printing?

    I thought maybe since the printer is hooked into a PC do i need to install the windows printer drivers on the mac?

  • Hello Community...Macbook w 10.6.8 and I need printing help. Using three canon photo printers of same model and need them to print individually. They are older and NOT network-able. Currently using another Mac to print to 2nd printer. 3 is idle.

    Is there software available where all I have to do is hit print and any of the 4x6 printers will print? Once I get this issue settled, I'll get a second larger format. I have to get this rectified because of time and ease. As mentioned, I have a second mac that I share screens with so my assistant can find pics for customers while I'm shooting. So, I can print through that mac to the printer. (ie....print to canon@##%#@Mac 2) I don't want to bring a third computer just to print to three of the same model printer. (That's what I've been doing) BTW....I totally know there are faster dye-sub printers out there but I'm about 4 more events from purchasing one...($$$) Some print under 10 seconds. I would appreciate any answers out there. Thank you.

    I don't have that printer and I'm not on Mac, so someone else has to step in there. Generally a green/magenta cast indicates none/double printer color management. But then I don't know what you mean by "slight".
    The Spyders aren't the most consistent and reliable calibrators out there. I had a Spyder 3 sensor that I just threw away because it gave a distinct red cast (I have several other calibrators, so there was no doubt). Another potential problem is that with most calibrators you can only adjust the white point along the blue/yellow Kelvin scale, but not on the green/magenta scale. This is often necessary to get a good white point color. In this case you need to use the monitor's OSD controls, and if possible the "pre-calibration" function in the calibrator to measure and monitor it - if that function exists. And I don't know if this is possible with an iMac.
    This is basically a question of getting the white point right, both on the blue/yellow and the green/magenta axis (and luminance of course). The goal is to get a visual match to paper white on screen. With the white point properly set, neutral color balance relates to that, and the rest more or less follows by itself. (In addition you should set the proper black point/contrast for full control, but that's not the issue here).

  • I need to help with splash top / quick start. I am getting and error message when run the app.

    I just receive this computer in mar 2009. I found this app out and try to install it. When I go to run it give me error message. The installation is not complete please repair the software. I also update my bios like it says. It will not run can you help me fix this issue. I like this app. I want it to work.

    This page http://forum.lenovo.com/lnv/board/message?board.id=IdeaPad_Netbook&thread.id=1742  provides helpful information on how to activate Splashtop on S10. 
    If it still can't help you,  I guess you will get more help if you can provide more information like your detailed netbook version, os information, and the detailed error information.
    Message Edited by DouDou2007 on 03-23-2009 12:24 AM

  • I need printing help.

    Hello All.
    I am trying to print a document with InDesign or Acrobat Reader. I'm on MAC OSX using all CS3 adobe product.
    I've created a 75 page document and the dimensions of each page are 8.75"W x 5.625"H. It's a custom size. I've set up a custom size in my printer settings on my Epson R300 but cannot get it to print. I've even changed the printer set up to a standard size that is close in dimensions but still it won't print.
    I can print other documents from other software. But I'm having trouble printing this specific one as well as other's from all of my adobe software.
    Any ideas?
    Thanks.

    Hi Mike.
    When I try to print- the print fails. I open up my print utility and there is my process just sitting idle. I try to restart it and OSX thinks for a bit and then puts a hold on the document.
    When I click on print preview. Everything looks fine.
    Could this be something to do with my fonts? Recently while loading in a bunch of new fonts all my adobe software stopped working completely. I had to uninstall and reinstall all of it.
    I scoured the adobe forum and found that sometimes fonts cause software problems.
    Thanks

  • Need some help. The top menu bar disappears when in an app...?????

    I recently came across a problem that when I go into an application, for example MAIL, the above menu bar disappears. I am not able to access anything that would be in the above MAIL menu bar. I am still able to write/send/check mail but if I wanted to edit or change something the bar is not there. When I minimize MAIL or any other application I'm in and click on the desktop then the finder menu bar appears again. I'm not sure how to fix this...Thanks for any help someone can offer.

    Try restarting the Mac and see if that helps.

  • Just updated itunes now menu bar has dissapeared no black and white box at top left and ctr b does not bring anything up. i need file view etc please help driving me crazy

    just updated itunes now menu bar has dissapeared no black and white box at top left and ctr b does not bring anything up. i need file view etc please help driving me crazy

    Is the iTunes window in FullScreen mode?
    If so, press esc key.

  • P3005 prints two letters top left before print job- Help Pls.

    It just started doing it and it doesn't happen all the time either. It's very frustrating when I am printing cheques and the first cheque gets used with just two letters in the top left and then the actual print job starts with the second cheque.
    I've tried uninstalling the printer and re-installing it but that doesn't help. It's not consistant either.
    It also has started happening on another co-workers printer a HP 4250. These printers are not networked and are hooked up to our PC's (Windows XP).
    I am the tech guy for our hotel but not a professional and I can't figure it out. No settings have been changed.

    You can have the msgsend calss as an utility class
    with out a main method. Change the main method to
    some other name like sendMessage.
    import that class in your servlet email2.
    If msgsend is in a package, you can do import somepackage.msgsend
    msgsend emailMes =new msgsend(filename);
    then,
    emailMes.sendMessage();
    Hope this helps.

  • I'm missing the "foxfire" button. It's simply not there and I need to re-import my IE favorites, but I can't becasue the new upgrade forces you, (me), to use a button that simply is not there at the top left where it should be but isn't.

    Well that's pretty much it. The foxfire help page, now that I've upgraded to the newest version says to look for the "foxfire" button at the top left which would be located in the blue bar that instead still tells me what the name of that particular page is that I am viewing, just as it always has but there is no "foxfire button there for me to click on in order to get my bookmarks, my favorites re-imported from IE version 6.0. I actually installed them via the instructions under foxfire version 6.0 a month ago originally without any problem, and then again on version 7.0 after I recently rebuilt this machine using windows 2000 professional and everything got imported Okay except for one file... And of course it was the most important folder, my favorites folder which I had named "business" because it was the folder which contained all my links that I need for "business". So naturally, I am eagerly awaiting a reply to tell me what it is that I need to do. Could it be as simple as I have not re-booted since I upgraded earlier today/yesterday? That actually IS a possibility I suppose because I don't remember re-booting afterward or being told to in or after the process of upgrading. After the upgrade, there simply was not any indication that I needed to. (As I recall anyhow!) It's currently one in the morning and that was twelve hours ago. But I honestly don't think that I was instructed to after clicking on "install" the new version. But if it did tell me to afterward, I'm sure I must have even though I don't remember it as my extensive history with personal computing and installing everything from hardware to software including operating systems tells me that if it had told me to re-boot, I would have.
    Thank you in advance,
    Eric G.

    You are on Windows 2000, you do not have a "Firefox" button, and should consider yourself to be fortunate in that you still have menus and don't have to do anything to get the menus back instead of the "Firefox" button. (The same applies to Windows XP users).
    Use the "File" menu to get to Import. You are not on Windows 7 or Vista, and don't have to put up with the nonsense added for Aero.
    If you want the "Firefox" button you can get it with View -> toolbars -> (uncheck) Menu Bar. The menu bar and the "Firefox" button were supposed to be mutually exclusive (which is impossible in some cases without being incompatible).
    Once you are using the "Firefox" button ...
    Use the "Alt" key to view the menu bar (temporarily) containing File, Edit, View, History, Bookmarks, Tools, and Help. On Windows 7 and Vista, the menu bar was hidden by default in Firefox 4 and above. These menu items are more or less available under the "Firefox" button which has the most used of the built-in Firefox menu items available in a different format.
    To get back to having menus again. "Firefox" button -> Options (second column) -> (check) Menu Bar
    You can make '''Firefox 7.0.1''' look like Firefox 3.6.*, see numbered '''items 1-10''' in the following topic [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 thru 8.0, look like 3.6)]. ''Whether or not you make changes, you should be aware of what has changed and what you have to do to use changed or missing features.''
    * http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface

  • Multi-Page Printing (Please I need realy help)

    Dear Friend !
    Please Help me. My Dateline is running out quickly.
    I have a problem, I could not Print multi-page text document which are directly retrive from MS Access DataBase.
    I send by code for your easy understanding. Please, I realy need help.
    It prints multi-page but prints dublicate the first page.
    For multi-page print, look at Bolded Text in the Last Part of the code.
    Thank u very much.
    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import java.sql.*;
    import java.util.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    import java.text.SimpleDateFormat;
    public class printBalance{
    int maxPage=1;
    int pHight=0;
    int header=0;
    FontMetrics fontMet2;
    private final static int POINTS_PER_INCH=15;
    Paper paper=new Paper();
    //paper.setSize(612,792);
    public printBalance () {
    //--- Create a new PrinterJob object
    PrinterJob printJob = PrinterJob.getPrinterJob ();
    //--- Create a new Book to add pages to
    Book book = new Book ();
    //--- Add the cover page using the default page format for this print job
    // book.append (new IntroPage (), printJob.defaultPage ());
    //--- Add the document page using a landscape page format
    PageFormat documentPageFormat = new PageFormat ();
    paper.setImageableArea(15,15,580,648);
    documentPageFormat.setPaper(paper);
    documentPageFormat.setOrientation (PageFormat.PORTRAIT);
    book.append (new Document (), documentPageFormat);
    //--- Add a third page using the same painter
    book.append (new Document (), documentPageFormat);
    //--- Tell the printJob to use the Book as the Pageable object
    printJob.setPageable (book);
    //--- Show the print dialog box. If the user clicks the
    //--- print button, we then proceed to print, else we cancel
    //--- the process.
    if (printJob.printDialog()) {
    try {
    printJob.print();
    } catch (Exception PrintException) {
    PrintException.printStackTrace();
    private class Document implements Printable {
    public int print (Graphics g, PageFormat pageFormat, int page) {
    //--- Create the Graphics2D object
    Graphics2D g2d = (Graphics2D) g;
    //--- Translate the origin to 0,0 for the top left corner
    g2d.translate (pageFormat.getImageableX (), pageFormat.getImageableY ());
    //--- Set the drawing color to black
    g2d.setPaint (Color.black);
    //--- Print the title
    DataLink dbTitle=new DataLink();
    ResultSet rsTitle;
    String TitleQuery="Select Com_ID,Com_Name,Com_Road,Com_House,Com_Add,Com_City from Company_Profile where Com_ID='001'";
    Vector tempAdd=new Vector();
    //--- Compute the horizontal center of the page
    FontMetrics fontMetrics = g2d.getFontMetrics ();
    try{
                   rsTitle=dbTitle.stmt.executeQuery(TitleQuery);
                   rsTitle.next();
    String titleName=rsTitle.getString(2);
    tempAdd.addElement(rsTitle.getString(3));
    tempAdd.addElement(rsTitle.getString(4));
    tempAdd.addElement(rsTitle.getString(5));
    tempAdd.addElement(rsTitle.getString(6));
    String titleAdd=(tempAdd).toString();
    Font titleFont2 = new Font ("helvetica", Font.PLAIN, 13);
    //titleFont2.getFont(titleName);
    g2d.setFont (titleFont2);
    //--- Compute the horizontal center of the page
    //--- Compute the horizontal center of the page
    double titleX = (pageFormat.getImageableWidth () / 2) - (fontMetrics.stringWidth (titleName) / 2);
    //System.out.println(titleName);
    double titleY =POINTS_PER_INCH;
    g2d.drawString (titleName, (int) titleX, (int) titleY);
              double titleX3 = (pageFormat.getImageableWidth () / 2) - (fontMetrics.stringWidth (titleAdd) / 2);
              //System.out.println(titleAdd);
              double titleY3 =POINTS_PER_INCH+fontMetrics.getHeight();
    g2d.drawString (titleAdd, (int) titleX3, (int) titleY3);
    catch(SQLException ex){System.out.println(ex);}
    DataLink dbDate=new DataLink();
    ResultSet rsDate;
    String Qr="Select * from TimeSchedule where Com_ID='001'";
    Vector tempDate=new Vector();
    SimpleDateFormat dateformat = new SimpleDateFormat("MMMMMMMM. dd, yyyy",Locale.getDefault());
    FontMetrics fontMet = g2d.getFontMetrics ();
    try{
                   rsDate=dbDate.stmt.executeQuery(Qr);
                   rsDate.next();
    tempDate.addElement("BALANCE SHEET AS AT ");
    tempDate.addElement(String.valueOf(dateformat.format(rsDate.getDate(2))));
    String BalanceDate=(tempDate).toString();
    Font titleFont2 = new Font ("helvetica", Font.PLAIN, 13);
    //titleFont2.getFont(titleName);
    g2d.setFont (titleFont2);
    //--- Compute the horizontal center of the page
    //--- Compute the horizontal center of the page
    double DateX = (pageFormat.getImageableWidth () / 2) - (fontMet.stringWidth (BalanceDate) / 2);
    //System.out.println(BalanceDate);
    double DateY =POINTS_PER_INCH+POINTS_PER_INCH+fontMet.getHeight();
    g2d.drawString (BalanceDate, (int) DateX, (int) DateY);
    catch(SQLException ex){System.out.println(ex);}
    Rectangle2D.Double borderHead = new Rectangle2D.Double (0,
    fontMetrics.getHeight()+fontMetrics.getHeight()+fontMet.getHeight()*2,
    pageFormat.getImageableWidth (),
    fontMet.getHeight());
    Font font=new Font("Arial",Font.PLAIN,12);
    g2d.setFont (font);
    g2d.drawString("CAPITAL & LIABILITIES",POINTS_PER_INCH,fontMetrics.getHeight()*5);
    g2d.drawLine(POINTS_PER_INCH*14,(fontMetrics.getHeight()*4)+4,POINTS_PER_INCH*14,fontMetrics.getHeight()*5);
    g2d.drawString("AMOUNT",POINTS_PER_INCH*14+12,fontMetrics.getHeight()*5);
    g2d.drawString("PROPERTY & ASSETS",POINTS_PER_INCH*20,fontMetrics.getHeight()*5);
    g2d.drawLine(POINTS_PER_INCH*33,(fontMetrics.getHeight()*4)+4,POINTS_PER_INCH*33,fontMetrics.getHeight()*5);
    g2d.drawString("AMOUNT",POINTS_PER_INCH*34,fontMetrics.getHeight()*5);
    //--- Draw a border around the page using a 12 point border
    //g2d.setStroke (new BasicStroke (12));
    Rectangle2D.Double border = new Rectangle2D.Double (0,
    fontMetrics.getHeight()+fontMetrics.getHeight()+fontMet.getHeight()+fontMet.getHeight()*2,
    pageFormat.getImageableWidth (),
    pageFormat.getImageableHeight ());
    g2d.draw (borderHead);
    g2d.draw (border);
    /*Line2D.Double line = new Line2D.Double ();
    int j=(int)pageFormat.getImageableWidth()/2;
    line.setLine (j,0,j,pageFormat.getHeight());
    g2d.draw (line);*/
    int j=(int)pageFormat.getImageableWidth()/2;
    g2d.drawLine(j,fontMetrics.getHeight()+fontMetrics.getHeight()+fontMet.getHeight()*2,j,(int)pageFormat.getHeight());
    Vector temp=new Vector();
    //--- Print page 1
    if( page >= maxPage )
                   return NO_SUCH_PAGE;
    //if (page == 0) {
    DataLink db=new DataLink();
    DataLink db2=new DataLink();
    DataLink dbMinus=new DataLink();
              ResultSet rs;
              ResultSet rs1;
              DataLink dbMinus2=new DataLink();
              ResultSet rsSub;
    String Qry="SELECT Account_Name, Com_ID FROM Authorised_Capital Where Com_ID='001' GROUP BY Account_Name,Com_ID";
    //System.out.println(Qry);
    String getAccount="";
    String getDes="";
    double getAmount=0;
    String Amount="";
    DecimalFormat df=new DecimalFormat("###,###");
    int GrandTotal=0;
    int sum=0;
    int sum2=0;
    String val="";
    int k=0;
    int i=0;
    int U=0;
    int W=0;
    int J=0;
    int Z=0;
                   String ab = " ";
                   String FPart="";
                   String LPart="";
                   String strt="";
    String SubValu="";
                   try{
                   rs=db.stmt.executeQuery(Qry);
                   i=0+fontMetrics.getHeight()+fontMetrics.getHeight()+fontMet.getHeight()+fontMet.getHeight()*2;
                   while(rs.next())//where 1
    getAccount=rs.getString(1);
    //font//helvetica
    fontMet2 = g2d.getFontMetrics ();
    Font titleFont = new Font ("Arial", Font.PLAIN,10);
    g2d.setFont (titleFont);
    System.out.println("Font titleFont = new Font Arial, Font.PLAIN,10) =="+fontMet2.getHeight());
                   //--- Print the text one inch from the top and left margins
                        g2d.drawString (getAccount, POINTS_PER_INCH, POINTS_PER_INCH+i);
                        g2d.drawLine (POINTS_PER_INCH,POINTS_PER_INCH+i+10,POINTS_PER_INCH+140, POINTS_PER_INCH+10+i);
    String Qry2="SELECT Account_Name,Des,Amount,Formula FROM Authorised_Capital where Account_Name='"+getAccount+"' And Com_ID='001' And Formula='PLUS'";
    String Qry_Minus="SELECT Account_Name,Des,Amount,Formula FROM Authorised_Capital where Account_Name='"+getAccount+"' And Com_ID='001' And Formula='MINUS'";
    // Plus Row Count
    ResultSet count;
    count=db2.stmt.executeQuery(Qry2);
    int Cun=0;
    while(count.next())
    Cun =Cun+1;
    //Minus Row Count
    ResultSet Rs_Minus;
    Rs_Minus=dbMinus.stmt.executeQuery(Qry_Minus);
    int Minus_Count=0;
    while(Rs_Minus.next())
    Minus_Count =Minus_Count+1;
    //System.out.println(Minus_Count);
    rs1=db2.stmt.executeQuery(Qry2);
    k=i+20;
    sum=0;
    while(rs1.next())
    if(Cun>1){// multipule row
    getDes=rs1.getString(2);
    int ln= getDes.length();
    if(ln>19){
    boolean tr=false;
    ab = " ";
    FPart="";
    LPart="";
    strt=getDes.substring(19);
              int length=strt.length();
    //System.out.println("Length="+length);
                        for(int st=0; st<length; st++)
                        char ch=strt.charAt(st);
                        String vlu=String.valueOf(ch);
                        //System.out.println(vlu);
                        if(ab.compareToIgnoreCase(vlu)==0)
    tr=true;
                                  int Final=strt.indexOf(vlu);
                                  FPart=getDes.substring(0,19+Final);
                                  LPart=strt.substring(Final+1);
                                  g2d.drawString (FPart, POINTS_PER_INCH, POINTS_PER_INCH+k);
                                  k=k+10;
    g2d.drawString (LPart, POINTS_PER_INCH, POINTS_PER_INCH+k);
    break;
    }//end for
    if(tr==false)
    g2d.drawString (getDes, POINTS_PER_INCH, POINTS_PER_INCH+k);
                             }//end ln (if)
                        else {
                             g2d.drawString (getDes, POINTS_PER_INCH, POINTS_PER_INCH+k);
    String valComa=String.valueOf(df.format(Double.parseDouble(rs1.getString(3))));
    val=rs1.getString(3);
    Amount=val;
    int getAount=Integer.parseInt(Amount);
                        int len=valComa.length();
                        int B;
                        U=0;
                        for(B=len;B>0;B--)
    char num=valComa.charAt(B-1);
                        g2d.drawString (String.valueOf(num), POINTS_PER_INCH+170-U, POINTS_PER_INCH+k);
                        U =U+5;
    sum =sum+getAount;
    k =k+10;
                        }//end if // multipule row
                        else {
              getDes=rs1.getString(2);
    ab = " ";
    FPart="";
    LPart="";
    strt=getDes.substring(19);
              int length=strt.length();
    //System.out.println("Length="+length);
                        for(int st=0; st<length; st++)
                        char ch=strt.charAt(st);
                        String vlu=String.valueOf(ch);
                        if(ab.compareToIgnoreCase(vlu)==0)
                                  int Final=strt.indexOf(vlu);
                                  FPart=getDes.substring(0,19+Final);
                                  LPart=strt.substring(Final+1);
                                  //System.out.println(FPart+"\n"+LPart);
    g2d.drawString (FPart, POINTS_PER_INCH, POINTS_PER_INCH+k);
    k=k+10;
    g2d.drawString (LPart, POINTS_PER_INCH, POINTS_PER_INCH+k);
    //Only for Grand Total
    int Gnd=Integer.parseInt(rs1.getString(3));
    GrandTotal=GrandTotal+Gnd;
                        System.out.println(GrandTotal);
    val=String.valueOf(df.format(Double.parseDouble(rs1.getString(3))));
                        int len=val.length();
                        int C;
                        int D=0;
                        for(C=len;C>0;C--)
    char num=val.charAt(C-1);
                        g2d.drawString (String.valueOf(num), POINTS_PER_INCH+250-D, POINTS_PER_INCH+k);// Total
                        D =D+5;
    k =k+10; }//end else*/
                        }//end Where
                        // Calculate Total
                        if(Minus_Count>=1) //if 1
    if(!(sum==0.0)) //if 2
    String valComa=String.valueOf(df.format(sum));
                        int len=valComa.length();
                        int y;
                        int P=0;
                        W=10;
                        W=W+k;
                        for(y=len;y>0;y--)
    char num=valComa.charAt(y-1);
                        g2d.drawLine (POINTS_PER_INCH+80, POINTS_PER_INCH+k,200,POINTS_PER_INCH+k);
                        g2d.drawString (String.valueOf(num), POINTS_PER_INCH+170-P, POINTS_PER_INCH+W);
                        P =P+5;
                        }//end for
                   }//end if 2
                   rsSub=dbMinus2.stmt.executeQuery(Qry_Minus);
    int X=20;
    X=X+W;
    while(rsSub.next()) //while ##
    if(Minus_Count>1){//// for multipul line
    getDes=rsSub.getString(2);
    // System.out.println(getDes);
    int ln= getDes.length();
    if(ln>19){// for line is geter than 19
    boolean tr=false;
    ab = " ";
    FPart="";
    LPart="";
    strt=getDes.substring(19);
              int length=strt.length();
    X=X+10;
                        for(int st=0; st<length; st++)
                        char ch=strt.charAt(st);
                        String vlu=String.valueOf(ch);
                        //System.out.println(vlu);
                        if(ab.compareToIgnoreCase(vlu)==0)
    tr=true;
                                  int Final=strt.indexOf(vlu);
                                  FPart=getDes.substring(0,19+Final);
                                  LPart=strt.substring(Final+1);
                                  g2d.drawString (FPart, POINTS_PER_INCH, POINTS_PER_INCH+X);
                                  X=X+10;
    g2d.drawString (LPart, POINTS_PER_INCH, POINTS_PER_INCH+X);
    //X=X+10;
    break;
    }//end for
    if(tr==false)
    g2d.drawString (getDes, POINTS_PER_INCH, POINTS_PER_INCH+X);
                             }//end ln (if) // for line is geter than 19
                        else {
                             getDes=rsSub.getString(2);
                             int ln2= getDes.length();
                             /*if(ln2>19){
                             boolean tr=false;
                             ab = " ";
                             FPart="";
                             LPart="";
                             strt=getDes.substring(19);
                             int length=strt.length();
                             X=X+10;
                             for(int st=0; st<length; st++)
                             char ch=strt.charAt(st);
                        String vlu=String.valueOf(ch);
                        if(ab.compareToIgnoreCase(vlu)==0)
    tr=true;
                                  int Final=strt.indexOf(vlu);
                                  FPart=getDes.substring(0,19+Final);
                                  System.out.println("First part= "+Final);
                                  LPart=strt.substring(Final+1);
                                  System.out.println("Last part= "+LPart);
                                  g2d.drawString (FPart, POINTS_PER_INCH, POINTS_PER_INCH+X);
                                  X=X+10;
    g2d.drawString (LPart, POINTS_PER_INCH, POINTS_PER_INCH+X);
    //X=X+10;
    break;
    }//end for
    if(tr==false)
    g2d.drawString (getDes, POINTS_PER_INCH, POINTS_PER_INCH+X);
                        System.out.println("Plane line= ");
                             }//end ln (if)*/
                             g2d.drawString (getDes, POINTS_PER_INCH, POINTS_PER_INCH+X);
                             }//end else
    String valComa=String.valueOf(df.format(Double.parseDouble(rsSub.getString(3))));
    val=rsSub.getString(3);
    Amount=val;
    int getAount=Integer.parseInt(Amount);
                        int len=valComa.length();
                        int B;
                        U=0;
                        for(B=len;B>0;B--)
    char num=valComa.charAt(B-1);
                        g2d.drawString (String.valueOf(num), POINTS_PER_INCH+170-U, POINTS_PER_INCH+X);
                        U =U+5;
    sum2 =sum2+getAount;
    }//end if //for multipul line
    else {
    SubValu=rsSub.getString(2);
    int ln= SubValu.length();
              if(ln>19){// for line is geter than 19
              boolean tr=false;
              ab = " ";
              FPart="";
              LPart="";
              strt=SubValu.substring(19);
              int length=strt.length();
              X=X+10;
              for(int st=0; st<length; st++)
              char ch=strt.charAt(st);
              String vlu=String.valueOf(ch);
              //System.out.println(vlu);
              if(ab.compareToIgnoreCase(vlu)==0)
                             tr=true;
                        int Final=strt.indexOf(vlu);
                        FPart=SubValu.substring(0,19+Final);
                        LPart=strt.substring(Final+1);
                        g2d.drawString (FPart, POINTS_PER_INCH, POINTS_PER_INCH+X);
                        X=X+10;
                             g2d.drawString (LPart, POINTS_PER_INCH, POINTS_PER_INCH+X);
                             //X=X+10;
                             break;
                   }//end for
                   if(tr==false)
                   g2d.drawString (SubValu, POINTS_PER_INCH, POINTS_PER_INCH+X);
                   }//end ln (if) // for line is geter than 19
    else{
    //SubValu=rsSub.getString(2);
                        g2d.drawString (String.valueOf(SubValu), POINTS_PER_INCH, POINTS_PER_INCH+X);
    String valComa=String.valueOf(df.format(Double.parseDouble(rsSub.getString(3))));
    SubValu=rsSub.getString(3);
    int LessAount=Integer.parseInt(SubValu);
                        int Sublen=valComa.length();
                        int B;
                        int G=0;
                        for(B=Sublen;B>0;B--)
    char SubNum=valComa.charAt(B-1);
                        g2d.drawString (String.valueOf(SubNum), POINTS_PER_INCH+170-G, POINTS_PER_INCH+X);
                        G =G+5;
    int Actual_Value=sum-LessAount;
    String valCom=String.valueOf(df.format(Actual_Value));
                        int Lesslen=valCom.length();
                        int T;
                        int Q=0;
                        for(T=Lesslen;T>0;T--)
    char LessNum=valCom.charAt(T-1);
                        g2d.drawString (String.valueOf(LessNum), POINTS_PER_INCH+250-Q, POINTS_PER_INCH+X+10);
                        Q =Q+5;
                        k =X+20;
                   //}//end else
    }//end else*/
                        }//while ##
    if(Minus_Count>1){
    if(!(sum2==0.0)) //if 2
                   //System.out.println("Khaled");
    String valCom=String.valueOf(df.format(sum2));
                        int lent=valCom.length();
                        int y;
                        int P=0;
                   Z=10;
                        //System.out.println(X);
                        Z=Z+X;
                        //System.out.println("X="+X);
                        for(y=lent;y>0;y--)
    char num=valCom.charAt(y-1);
                        g2d.drawLine (POINTS_PER_INCH+80, POINTS_PER_INCH+Z,200,POINTS_PER_INCH+Z);
                        g2d.drawString (String.valueOf(num), POINTS_PER_INCH+170-P, POINTS_PER_INCH+Z+10);
                        P =P+5;
                        }//end for
                   k =Z+20;
                   }//end if 2
                        // }//end if(Minus_Count>1)
                        int FinalValue=sum-sum2;
                        //System.out.println("FinalValue="+FinalValue);
                        String valCom=String.valueOf(df.format(FinalValue));
                        int lent=valCom.length();
                        int y;
                        int P=0;
                   //Z=10;
                        //System.out.println(X);
                        //Z=Z+X;
                        for(y=lent;y>0;y--)
    char num=valCom.charAt(y-1);
                        g2d.drawString (String.valueOf(num), POINTS_PER_INCH+250-P, POINTS_PER_INCH+Z+10);
                        P =P+5;
                        }//end for
    }//if(Minus_Count>1)
                             }//end if 1
                   else{
                        //i =i+20+k;
    if(!(sum==0.0)) //if 2
    String valComa=String.valueOf(df.format(sum));
                        int len=valComa.length();
                        int y;
                        int z=0;
                        for(y=len;y>0;y--)
    char num=valComa.charAt(y-1);
                        g2d.drawString (String.valueOf(num), POINTS_PER_INCH+250-z, POINTS_PER_INCH+k);// Total
                        z =z+5;
                        }//end for
                   }//end if 2
                   }//end else*/
    i=k+30;
              }//end where 1
                   catch(SQLException ex)
                        System.out.println(ex);
    // For Grand Total
    String valComa=String.valueOf(df.format(GrandTotal));
                   int len=valComa.length();
                   int y;
                   int z=0;
    int h=0;
    h=k+40;
                   for(y=len;y>0;y--)
                   char num=valComa.charAt(y-1);
                   g2d.drawLine (POINTS_PER_INCH+255, POINTS_PER_INCH+h-10,POINTS_PER_INCH+250-z,POINTS_PER_INCH+h-10);
                   g2d.drawString (String.valueOf(num), POINTS_PER_INCH+250-z, POINTS_PER_INCH+h);// Total
                   z =z+5;
                   System.out.println(valComa);
                   }//end for
    /* String RowCount="SELECT * FROM Authorised_Capital where Com_ID='001'";
    DataLink dbCount=new DataLink();
    int RowCun=0;
    ResultSet roCount;
    try{
                        roCount=dbCount.stmt.executeQuery(RowCount);
                        while(roCount.next())
                        RowCun =RowCun+1;
                   catch(SQLException ep){}*/
    int header =fontMetrics.getHeight()*5;
    System.out.println("Header ="+header);
    int H=fontMet2.getHeight();
    int row=H + fontMet2.getDescent();
    System.out.println("Page row= "+row);
    pHight=(int)pageFormat.getImageableHeight();
    System.out.println("Page Height= "+pHight);
    int rowPerPage = (pHight-header)/row;
    System.out.println("Row per page= "+rowPerPage);
    double rowN = h-header;
    double rowNumber = rowN/row;
    System.out.println("Row Numbe= "+rowNumber);
    maxPage = Math.max( (int)Math.ceil(rowNumber/(double)rowPerPage), 1);
    System.out.println("maxPage ="+maxPage);
    return (PAGE_EXISTS);
    //--- Print page 2
    /*else if (page == 2) {
    //--- Print the text one inch from the top and left margins
    g2d.drawString ("This the content of the second page: " + page, POINTS_PER_INCH, POINTS_PER_INCH);
    return (PAGE_EXISTS);
    //--- Validate the page
    //return (NO_SUCH_PAGE);
    }// end public int print (Graphics g, PageFormat pageFormat, int page)
    Message was edited by:
    khaled200
    Message was edited by:
    khaled200

    I implemented an example here.
    http://java-sl.com/Pagination_In_JEditorPane_Print.html
    Regards,
    Stas

  • C3180 is printing 2345x in top left corner of blank pages every time i print

    Every time I print anything from my Mac Book Pro (running Mavericks 10.9), my C3180 spits out a page with 2345x printed in the top left corner of an otherwise blank page.  Wasting my paper and my ink.  
    Anyone have any suggestions?
    This question was solved.
    View Solution.

    Thanks all for the information.  We are taking a look at what this might be.    Is it printing this out on a single sheet after the desired print, or on the same page or a combination?  Any additional details will greatly help trying to track this issue down to root cause.

  • Could not lock and unlock my bb on the top left. PLEASE HELP ME

    Hi everybody. I really need your help. My bb is 9780 and suddenly my button lock and unlock on the top left doesn't seems like working. And now when i hold the alphabet 'A' my bb can be lock but when i want to unlock it ,i cant just seems to unlock it. The only way to unlock it and use my bb is to turn off (remove d battery)  my phone and restart it again.
    This is very troublesome. Please someone assist me in this and help me out.
    Really thank you all in advance.

    Just wait it out. Given how many people are having this issue, it seems to be on Apple's end, so all you can do is wait for them to fix it.

  • TS3406 I have a connection in the top left hand corner and can access the internet with and without internet on my iphone 5c but I can't receive and create texts and calls, someone please help have tried everything!

    I have a connection in the top left hand corner and can access the internet with and without internet on my iphone 5c but I can't receive and create texts and calls, someone please help have tried everything!

    YOu will need to contact your cell phone provider to resolve those issue, those are carrier features.

  • Printing on Top left Corner of a page

    Hi,
    I have written a java program to print , i am not able to print on the top left corner(Extreme),
    even though i specify my X and Y co-ordinates are 0 ,0 . please help me in printing on the top left corner .
    find below my java program.
         Author
         Manju
         PrinterJob prnJob = PrinterJob.getPrinterJob ();
    PrintDetails m_pr = new PrintDetails();
    // Create a new book to add pages to
    Book book = new Book ();
    PageFormat format = new PageFormat();
    Paper paper=new Paper();
    // Set the imagable area to 300.0 and 435.0
    paper.setImageableArea(0.0,0.0,300.0,435.0);
    // Set the paper size to 300 width and 435 width.
    paper.setSize(300,435);
    format.setPaper(paper);
    book.append (new Document (), format);
    // Tell the prnJob to use the Book as the Pageable object
    prnJob.setPageable (book);
    * Get the value from the properties file to print to
    * the appropriate printer (Preferred Printer)
    * Property names are
    * 1. PRINTER_1
    * 2. PRINTER_2
    * Example :-
    * PRINTER_1=Microsoft Office Document Image Writer
    * PRINTER_2=\\\\igtewf39\\TVS MSP 345/Champion/XL Classic
    * PRINTER_2 is having the proper value while PRINTER_1 is not.
    * Printer name should have the server name Pre-fixed to it.
    String prefferedPrinter = null;
    if(args.length > 0) {
    System.out.println("args0" + args[0]);
    if(args[0].equals("1")) {
    prefferedPrinter = m_pr.getProperty("PRINTER_1");
    else {
    prefferedPrinter = m_pr.getProperty("PRINTER_2");
    * Get the printer from the list.
    * Print the contents to the printer
    * There might be lot of Printers configured in the system
    * We have to get the contents printed on our preferred Printer.
    PrintService[] array = PrinterJob.getPrinterJob().lookupPrintServices();
    int device= -1;
    for (int i=0; i<array.length;i++)
    if(prefferedPrinter.equalsIgnoreCase(array.getName())) device=i;
    try {
    prnJob.setPrintService(prnJob.lookupPrintServices()[device]);
    // The number of copies can be changed to 2 or three . Default will be one.
    prnJob.setCopies(1);
    prnJob.print();
         } catch (Exception PrintException) {
         PrintException.printStackTrace();
    Regards
    Manju

    Most printers will not print to the very edge of the paper if the printer has been told what size paper is loaded and that is, in fact, what is loaded. Check the printer printing limits.

Maybe you are looking for