ned him

Greenhorn
+ Follow
since Aug 06, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ned him

what is the code for set a printer


PrintService[] service=PrinterJob.lookupPrintServices();
for(int i=0;i<service.length;i++)
System.out.println(" "+service[i].getName());

i gives out put :
TVS MSP 245/Classic/XL Classic
HP LaserJet 1020



BUT I WANT HOW TO SET THE PRINTER IS 'HP LaserJet 1020'
16 years ago
please give me java code for printer
'two computers are connected in network(192.168.0.1, 192.168.0.2 if i know ip address only)now i am run a program on computer1(192.168.0.1)for finding printerservices of printer to be connected to computer2(192.168.0.2).'
what is the code???
my program is given below
but i need for ' in a network 3 computers are connected with ipaddress 192.168.0.1, 192.168.0.2, 192.168.0.3. Each computer having a printer. Now i am run a program on computer1(192.168.0.1) at that time computer3's(192.168.0.3) printer is activate and gives printout'. what is the program

plese help me...

Main.java



public class Main

{ public static String text2print;
public static void main (String [] args) {
text2print="This rolls out the printer......";
Print dezetekst=new Print();
System.exit (0);
}
}


Print.java

import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.print.*;


public class Print extends Main {

private final static int POINTS_PER_INCH = 12;
//private String text2print;

public Print () {
//--- 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 ());
//--- Tell the printJob to use the book as the pageable object
printJob.setPageable (book);
try {
printJob.print();
} catch (Exception PrintException) {
PrintException.printStackTrace();
}
}
public void setPrint(String printmij)
{
text2print=printmij;
}

private class IntroPage 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 default drawing color to black
g2d.setPaint (Color.black);
//--- Print the title
String titleText = text2print;
Font titleFont = new Font ("arial", Font.BOLD, 12);
g2d.setFont (titleFont);
//--- Compute the horizontal center of the page
FontMetrics fontMetrics = g2d.getFontMetrics ();
double titleY = 3 * POINTS_PER_INCH;
double titleX =0;
g2d.drawString (titleText, (int) titleX, (int) titleY);
return (PAGE_EXISTS);
}
}
}
please help me for print on printer by javascript.
i am facing 4 problems.

1)how to set paper size is 3x3 inch.( but in java we use 'new paper.setSize(200,200)')

2)how to disable header and footer of paper(filename,date pageno,...)

3)how to print a hidden type textbox value without window.print()

4)how to catch printer problems
Below program is normal java program for print 2 strings on 3/3 inch page

but i want ' in a network 3 computers are connected with ipaddress 192.168.xxx.xxx. Each computer having a printer. Now i am running this program on computer1 at that time computer3's printer is activate and gives printout'. what is the program

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.LineBreakMeasurer;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterJob;
import java.text.AttributedString;
import java.util.Vector;
import java.awt.image.*;
import java.awt.*;
import java.awt.font.*;
import java.awt.print.Paper;
import java.awt.geom.*;
import java.awt.print.*;

public class Min12 {
public static String text2print;
public static String text1print;
public static void main (String [] args) {
text2print=" HAI ";
text1print="Hello....";
Pi dezetekst=new Pi();

}
}
class Pi extends Min12 {

private final static int POINTS_PER_INCH = 1;

private PageFormat pgFormat = new PageFormat();
private Book book = new Book();
private Paper p;
private int W;
private int H;

public Pi() {
p = new Paper();
p.setSize(W = 188, H = 188); //3" x 3"
// p.setImageableArea(20, 21, 2 ,286); //half inch margins
pgFormat.setPaper(p);
//--- Create a new PrinterJob object
PrinterJob printJob = PrinterJob.getPrinterJob ();
//--- Create a new book to add pages to
//--- Add the cover page using the default page format for this print job
book.append (new IntroPage (), pgFormat);
//--- Tell the printJob to use the book as the pageable object
printJob.setPageable (book);
try {
printJob.print();

} catch (Exception PrintException) {
PrintException.printStackTrace();
}
}
public void setPrint(String printmij)
{
text2print=printmij;
}

private class IntroPage implements Printable{


public int print (Graphics g, PageFormat pageFormat, int page) {
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint (Color.black);
String titleText = text2print;
String titleText1 = text1print;
g2d.setClip(null);
Font titleFont1 = new Font ("arial", Font.BOLD,30);
g2d.setFont(titleFont1);
g2d.drawString (titleText, 4,20);
Font titleFont2 = new Font ("arial", Font.PLAIN,18);
g2d.setFont (titleFont2);
g2d.drawString (titleText1, 10,35);
return (PAGE_EXISTS);
}
}
}


but i want ' in a network 3 computers are connected with ipaddress 192.168.xxx.xxx. Each computer having a printer. Now i am running this program on computer1 at that time computer3's printer is activate and gives printout'. what is the program
16 years ago
this is for normal java program for print 2 strings on 3/3 inch page

but i want in jsp program for client side printer to print these 2 strings on 3/3 inch page

[ August 08, 2007: Message edited by: Ben Souther ]
16 years ago
JSP
this is for normal java program for print 2 strings on 3/3 inch page

but i want in jsp program for client side printer to print these 2 strings on 3/3 inch page

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.LineBreakMeasurer;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterJob;
import java.text.AttributedString;
import java.util.Vector;
import java.awt.image.*;
import java.awt.*;
import java.awt.font.*;
import java.awt.print.Paper;
import java.awt.geom.*;
import java.awt.print.*;

public class Min12 {
public static String text2print;
public static String text1print;
public static void main (String [] args) {
text2print=" HAI ";
text1print="Hello....";
Pi dezetekst=new Pi();

}
}
class Pi extends Min12 {

private final static int POINTS_PER_INCH = 1;

private PageFormat pgFormat = new PageFormat();
private Book book = new Book();
private Paper p;
private int W;
private int H;

public Pi() {
p = new Paper();
p.setSize(W = 188, H = 188); //3" x 3"
// p.setImageableArea(20, 21, 2 ,286); //half inch margins
pgFormat.setPaper(p);
//--- Create a new PrinterJob object
PrinterJob printJob = PrinterJob.getPrinterJob ();
//--- Create a new book to add pages to
//--- Add the cover page using the default page format for this print job
book.append (new IntroPage (), pgFormat);
//--- Tell the printJob to use the book as the pageable object
printJob.setPageable (book);
try {
printJob.print();

} catch (Exception PrintException) {
PrintException.printStackTrace();
}
}
public void setPrint(String printmij)
{
text2print=printmij;
}

private class IntroPage implements Printable{


public int print (Graphics g, PageFormat pageFormat, int page) {
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint (Color.black);
String titleText = text2print;
String titleText1 = text1print;
g2d.setClip(null);
Font titleFont1 = new Font ("arial", Font.BOLD,30);
g2d.setFont(titleFont1);
g2d.drawString (titleText, 4,20);
Font titleFont2 = new Font ("arial", Font.PLAIN,18);
g2d.setFont (titleFont2);
g2d.drawString (titleText1, 10,35);
return (PAGE_EXISTS);
}
}
}
16 years ago
JSP