Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-07-2007, 05:42 PM
Member
 
Join Date: Aug 2007
Posts: 3
for453 is on a distinguished road
jsp program for client side printer to print these 2 strings on 3/3
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

Code:
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); } } }

Last edited by levent : 08-07-2007 at 08:06 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy a .swf file from server side to client using signed applet Imoracle Java Applets 0 01-28-2008 01:39 PM
How to print text file in java(dotmatrix printer) yoganeethi Advanced Java 1 12-13-2007 01:38 PM
please help on java program for printer : this printer is connected to system which for453 Java 2D 0 08-09-2007 07:30 AM
i want how to make aprint client side printer to print these 2 strings on 3/3 inch pa for453 Networking 0 08-06-2007 07:54 PM
How to implement secure connection(HTTPs) in client side vicky Networking 6 07-18-2007 04:15 PM


All times are GMT +3. The time now is 01:16 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org