Hi everyone,
I want to know how to print the contents of the text area including all its fonts to the printer. I have no idea how to implement this in awt. Could someone show me or e-mail me any sample codings on how the print functionality
can be implemented in awt and tell me what is the name of the api that i should be looking at.

My e-mail is freesoft_2000@yahoo.com

I really hope someone can help me

Yours Sincerely

Richard West

Here is a very basic example of how to print out a line of text in Java

import java.awt.*;
import java.awt.geom.*;
import java.awt.print.*;
/**
 Simple printing application that
 will demonstrate how to print out simple text
*/

class MyPage implements Printable
{
 public void paint (Graphics g)  // This method will define what will
 {	// be printed on paper 
  Graphics2D g2d = (Graphics2D) g;
  g2d.setFont(new Font("Arial", Font.BOLD, 30));
  g2d.drawString ("Hello World of Paper!", 200, 150);
	
 }
 public int print (Graphics g, PageFormat f, int i)
 {
  if (i != 0) // To prevent overflow. i indicates number of pages to print
   return NO_SUCH_PAGE;
  paint (g); // Call paint method
  return PAGE_EXISTS;
 }
}
class MyPrinter
{
 public static void main (String[] args)
 {
  PrinterJob job = PrinterJob.getPrinterJob(); 
  System.out.println ("Staring printer...");
  job.setPrintable(new MyPage());
  if (job.printDialog()) // Show the printing dialog
  {
   try {
	job.print(); // Attempt printing
   }
   catch (PrinterException e)
   {
	e.printStackTrace();
   }
  }
 }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.