java - Sending a Text Box control to the Printer? -
I can find out to send a text box control to print in Java.
The program word search creates puzzles, now I want to print them.
I just want to print the text box control as it is ... but I had to try other methods like this.
My first problem is that when I try to send it to txtEasy.getText () it actually tries to print a long string. I did not want this, so I really wanted to take a long string and parsize it like this. Rows of 15 words from 20 Unfortunately you can not see here But this is a box from 15 to 20.
MSN I T i SO P M O CLG D RB P UDC K S K GUBE I Q C D I N M. P P I UNPJ J U tnl i ncvd qbw i uu t ot ntf j ond ngtglgbrk cmm msw ghtasnn i gi u K XU X SEP I E QCTGCBO XHJNBDTTJP I think I am an AQQ ECSW I FOLM M NRT I am an ELPSPD Q O UU A P EHF I TSOF QNLLLLHDOQFAO AG TQA BS ASRWTCLTNPGNESTXTYPOVT I EWL QCF I HSEJFEMLADDNAEEN W K T QN I I K I J V S I G F & H E E P Y Y Jammu US H R D FVDRD I BEFRR I U.HUYE VSFOE Q JAMMU V RN V V RG RLG Q SBM FGA J
This is my code like this.
Currently it is setup, so I have sent the text as txtEasy.getText () to the printer class
I have a problem with this method now, the font is correctly Puzzle is not aligned.
Then my two questions ...
1) Is there a way to send text box control to the printer?
2) string font? The font size is generating my uneven print.
Thanks for any help.
Private zeros btnEasyPrintActionPerformed (java.awt.event.ActionEvent evt) {// System out.println (txtEasy.getText ()); Printjobjobjob = printerjob.jet printerjobe (); PrintRequestAttributeSet aset = New HashPrintRequestAttributeSet (); Page Format PF = Job Page Dialog (ASKT); Job.setPrintable (New PrintPuzzle (txtEasy.getText ()), PF; Boolean Fix = Job Print diagram (asset); If (OK) {try {job.print (aset); } Hold (pre-printer exception) {/ * Job did not complete successfully} // ******** Print class ******** Import java.awt. *; Import java.awt.print. *; Public Square PrintPuzzle tools printable {string to print; String formattedop print; Public PrintPuzzle (string item) {toPrint = item; // toPrint = item; // formatedToPrint = formatBoardToPrint (toPrint); } Public Entent Print (Graphics G, Page Format PF, Int page) throws printer exposure {if (page> gt; 0) {NO_SUCH_PAGE; } / * User (0,0) is usually out of the imageable area, so to translate X and Y values into page format to avoid * clipping * / graphics 2DG2D = (Graphics 2D) Will happen; G2d.translate (pf.getImgeableX (), pf.getImageableY ()); / * Now we have our rendering * / string pentam = "" ;;;; Int YPosition = 20; Int first = 2; Int final = 46; Println (toPrint); System.out.println ("string length is:" + toPrint.length ()); For (int i = 0; i
Whether your print () function is actually printing a matrix, Do not properly align properly
Call g2d.setFont () and set fixed-width font like courier, and it will make it right.
You can also call JTextBox.print () to print a dialog and content that will show
Comments
Post a Comment