CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2000
    Location
    bangalore,karnataka,india
    Posts
    2

    please help me in printing

    i want the contents of a textarea to be printed.
    if the contents span several pages , it should be printed correspodingly.
    please help me ,this is urgent.

    d j kaladhar

  2. #2
    Join Date
    Apr 2000
    Location
    CA, USA
    Posts
    1

    Re: please help me in printing

    i am also not able to
    print beyond my first page. the
    following is a snippet of my code
    and if you have any suggestions as
    to how i can make this work, i truly
    do appreciate it:

    try
    {
    PrintJob pj = getToolkit().getPrintJob(this, "HELLO", new Properties());
    if (pj != null)
    {
    Graphics g = pj.getGraphics();
    g.setFont(new Font("Courier New", Font.PLAIN, 10));
    g.setColor(java.awt.Color.white);
    int pageWidth = pj.getPageDimension().width;
    int pageHeight = pj.getPageDimension().height;
    System.out.println("WIDTH = " + pageWidth);
    System.out.println("HEIGHT = " + pageHeight);
    g.fillRect(0,0,pageWidth, pageHeight);//xMax-xMin,yMax-yMin);
    _summaryPanel.setBackground(java.awt.Color.white);
    _summaryPanel.printAll(g);//ok
    g.dispose();
    pj.end();

    Graphics g2 = pj.getGraphics();
    g2.setFont(new Font("Courier New", Font.PLAIN, 10));
    g2.setColor(java.awt.Color.black);
    _summaryPanel.setBackground(java.awt.Color.white);
    _summaryPanel.printAll(g2);//ok
    g2.dispose();
    pj.end();

    }
    }
    catch(Exception e)
    {
    System.out.println(e.getMessage());
    }


  3. #3
    Join Date
    Sep 2000
    Posts
    1

    Re: please help me in printing

    try to take off your first pj.end();




  4. #4
    Join Date
    Jan 2000
    Location
    CA, USA
    Posts
    305

    Re: please help me in printing

    Hi,
    How would you calculate the no. of pages to be
    printed using a TextArea component?

    Thanks,
    Kannan



  5. #5
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: please help me in printing

    The quick and dirty way would be to compute the total length of the text in the TextArea and divide it by the length of a page. Lengths being in pixels. However that could miss the case where a line will be split at the page end and would need to be carried to the next page. Use the FontMetrics class to get the size of the characters being printed.

    Norm
    Norm

  6. #6
    Join Date
    Apr 2001
    Posts
    42

    Re: please help me in printing

    Hey, take a look to www.nevaobject.com. This company offers for free some libraries that match exact your need. In few word there is about some libraries that make call API functions. Take a look for the JPrint.
    Try it. it works



    javalicious

    P.S. Sorry for my english

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured