How to print a text in java?
How to print a text in java?
of corse, i have JTextField in my frame that i want to extract the text and print it on a paper with a printer.
Similar Messages
-
How to print long text in scripts
plzzzzzzzzz answer this qestion
how to print long text in scriptsHi Kranthi,
You can create Text Id and include that in your script.
For example:
/E TEXT
/: INCLUDE ZTEXT OBJECT TEXT ID ST
Hope this helps.
Please reward if useful.
Thanks,
Srinivasa -
How to print the text in points wise in sap script
hi friends,
how to print the text in points wise in sap script.
ex: if suppose paragraph consists of 15 lines. then according to one sentence or one fullstop (.) it should give point 1. like that...
1. hai how ru.
2. what r u doing.
3.where r u.
like this i want numbering.. waiting for ur replys.
thanks,
kirandeclare a counter
data : cnt type char 4.
print :
cnt = cnt + 1.
&cnt& &text&
cnt = cnt + 1. and so on.
or.
if the data is in an internal table
loop at internal_table.
cnt = cnt + 1.
write form.
in script -&cnt& &text&
endloop.
Edited by: NIKHILKUMAR POOJARI on Nov 17, 2008 11:18 AM -
How to print the text in only last but one page in sapscripts
hiiiiiiiiiii,
explian how to print the text in only last but one page in sapscripts? wher to write the code? plz if possible explain in detail with an example?Hello,
The total no pages is given by &SAPSCRIPT-FORMPAGES& command.
So u can handle the situation in ur form like this
/: if &PAGE& = &SAPSCRIPT-FORMPAGES&
p1 TEXT
/: endif
Try in this way it may help u.
Regards -
How to Print a text in bold format in a classic report ??
How to Print a text in bold format in a classic report ??
hi
u can use
<b>FORMAT INTENSIFIED ON.</b>
regards
ravish
reward if useful -
How to print the texts retrived by using READ_TEXT fun module in Smartform
Please tell me how to print the text which is rertrived by using the READ_TEXT function module in smartform.
I have coded all things in the program lines and in that i am retriveing the long texts.
I am getting the text lines in my internal table clearly, the thing is that I am not able to pass these lines to the text.
I have to print the trouble ticket. in that the notes log I have to pass.
its urgent. Points will be rewarded for any type of clue. whether it will work or not.There are a few ways to do it. If you need to take all of the text in the text type, in your SF text element choose "Include Text".
Populate the fields with the data that corresponds to the text type. It is similar to the interface to the FM "Read_Text.
Text Name
Text Obje
Text ID
Language
Encase any variables with the "&" symbol.
If you have already coded the call to the FM "READ_TEXT" and loaded the text into an internal table, create a loop and loop through the itab. Inside of the loop create a text element and add a variable in the text element for the field you are looking to output. -
How to print Arabic text along with the English in smartform ( ECC6 version
Hi All,
our is ECC6 version, Non unicode, ABAP stack ( not dual stack )
is it possible to print in Arabic language in the above version ?
if yes, then please let me know how to print Arabic text and English text in the same smartfrom.
i tried in the following procedures :
1) i created standard text (SO10) in arabic language.
i called in the smartform ( include text - i )
langage AR
but system throws error message saying, required language is not installed.
2) if i use READ_TEXT function module.
text getting printed in diff format but not in arabic.
waiting for your replies..ECC6 and Non-Unicode? I think you'll need multiple code pages, I doubt there's a mixed Arabic/Latin1 available. And I don't think SAP supports new MDMP systems any more. If you need to support multiple languages you really need to go Unicode. It's probably easier to do the Unicode conversion than to try to support multiple code pages and you have to make the switch eventually.
-
How to print PDF files using java print API
Hi,
I was goign throw lot of discusion and reading lot of forums related to print pdf files using java api. but nothing seems to be working for me. Can any one tell me how to print pdf files using java api.
Thanks in advanceMike,
Can't seem to get hold of the example described in your reply below. If you could let us have the URL to get then it would be great.
My GUI application creates a pdf document which I need to print. I want to achieve this using the standard Java class PrinterJob (no 3rd party APIs I'm afraid, commercial restraints etc ..). I had a stab at it using the following code. When executed I get the pretty printer dialog then when I click ok to print, nothing happens!
boolean showPrintDialog=true;
PrinterJob printJob = PrinterJob.getPrinterJob ();
printJob.setJobName ("Contract.pdf");
try {
if (showPrintDialog) {
if (printJob.printDialog()) {
printJob.print();
else
printJob.print ();
} catch (Exception PrintException) {
PrintException.printStackTrace();
Thank you and a happy new year.
Cheers,
Chris -
I need to know how to print a text meassage to my printer?
I would like to know if anyone knows how to print a text message from your phone or from the pc?
1. Another option is using the "Google Cloud Printer" App. Yes there are times were I send myself a text message, in order to print it, and store it on my computer. Then there times are times that I use the Google Cloud Printer App.
2. You have the option to set-up the "Google Cloud Printer" App to use a classic printer or an e-printer. I do not have an e-printer, but I have used the classic printer method okay. -
Anybody know how you print off texts that have been sent to my iphone 4s,thankyou
anybody know how you print off texts that have been sent to my iphone 4s,thankyou.
Easiest way is to use something like this to import to your computer, then print them:
http://www.wideanglesoftware.com/touchcopy/index.php
Otherwise, you can take screen shots & print those. -
How to print a text file using Java
How can I print a text file using Java without converting the output to an image format. Is there anyway I can send the characters in the text file as it is for a print job? I did get a listing doing this ... but that converted the text to an image format before printing....
THanks,.Hi I had to write a print api from scratch, and I did not convert the output to image. Go and read up on the following code. I know there is a Tutorial on Sun about the differant sections of the snippet.
private void printReport()
Frame tempFrame = new Frame(getName());
PrintJob printerJob = Toolkit.getDefaultToolkit().getPrintJob(tempFrame, "Liesltext", null);
Graphics g = printerJob.getGraphics();
//I wrote the method below for calculations
printBasics(g);
g.dispose();
printerJob.end();
}This alone wont print it you have to do all the calculations in the printBasics method. And as I said I wrote this from scratch and all I did was research first the tutorial and the white papers
Ciao -
How to print a text file contents using java.
Using Input and Output streams I can add and retrive the contents to/from text file. But how to send this file contents to the printer or how to print the file.
Example from my code:
private void printErrorReport()
PrintJob pjob = getToolkit().getPrintJob(m_frame,null,null);
if (pjob != null) {
Graphics pg = pjob.getGraphics();
if (pg != null) {
String s = detailsArea.getText();
printLongString (pjob, pg, s);
pg.dispose();
pjob.end();
// Utility method needed
void printLongString (PrintJob pjob, Graphics pg, String s) {
int pageNum = 1;
int linesForThisPage = 0;
int linesForThisJob = 0;
// Note: String is immutable so won't change while printing.
if (!(pg instanceof PrintGraphics)) {
throw new IllegalArgumentException ("Graphics context not PrintGraphics");
StringReader sr = new StringReader (s);
LineNumberReader lnr = new LineNumberReader (sr);
String nextLine = " ";
int pageHeight = pjob.getPageDimension().height;
pageHeight -= 20;
Font helv = new Font("Arial", Font.PLAIN, 12);
//have to set the font to get any output
pg.setFont (helv);
FontMetrics fm = pg.getFontMetrics(helv);
int fontHeight = fm.getHeight();
int fontDescent = fm.getDescent();
int curHeight = 0;
try {
do {
nextLine = lnr.readLine();
if (nextLine != null) {
if ((curHeight + fontHeight) > pageHeight) {
// New Page
System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
pageNum++;
linesForThisPage = 0;
pg.dispose();
pg = pjob.getGraphics();
if (pg != null) {
pg.setFont (helv);
curHeight = 0;
curHeight += fontHeight;
if (pg != null) {
pg.drawString (nextLine, 0, curHeight - fontDescent);
linesForThisPage++;
linesForThisJob++;
} else {
System.out.println ("pg null");
} while (nextLine != null);
} catch (EOFException eof) {
// Fine, ignore
} catch (Throwable t) { // Anything else
t.printStackTrace();
System.out.println ("" + linesForThisPage + " lines printed for page " + pageNum);
System.out.println ("pages printed: " + pageNum);
System.out.println ("total lines printed: " + linesForThisJob);
} -
How to print a text file with long lines?
I am trying to print a text file which contains many long lines. I find that the long lines are truncated on the printouts. How do I wrap up these long lines? Could you give me some examples?
Thank you very much!Here's an example. The "\n" makes anything after it go to the next line. I hope this helps. Look at the Private void getTable() section.
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class LabNine extends Frame implements ActionListener, WindowListener {
private TextField txtInfo;
private List lstInfo;
private Button btnAddInfo;
private BorderLayout borderlayout;
private Connection databaseConnection;
Statement statement;
ResultSet resultSet;
public LabNine( ) {
super("Lab Nine");
// addWindowListener to close application
addWindowListener(this);
// create layout
borderlayout = new BorderLayout();
setLayout(borderlayout);
// create text field so the file input that is selected will be seen in here
txtInfo = new TextField();
txtInfo.setEnabled(false);
Color color = new Color(255, 136, 183);
txtInfo.setBackground(color);
add(txtInfo, BorderLayout.NORTH);
// create list so the file input can be populated in here
lstInfo = new List();
add(lstInfo, BorderLayout.CENTER);
// create button to add selected input file in the text field
btnAddInfo = new Button("Add Info");
btnAddInfo.setBackground(Color.cyan);
btnAddInfo.setFont(new Font("TimesRoman", Font.BOLD, 16));
btnAddInfo.addActionListener( this );
add(btnAddInfo, BorderLayout.SOUTH);
// set frame attributes
setSize(450, 250);
setResizable( false );
show();
// get the table/ get the query
loadConnection();
getTable();
public void actionPerformed(java.awt.event.ActionEvent e) {
// if add button is pushed then it will check to see if an item was selected.
// if not, then an error message will be displayed else the selected item will be in the text box
if ( e.getSource() == btnAddInfo ) {
if ( lstInfo.getSelectedIndex() == -1 ) {
System.out.print( "You have not selected an item" );
else {
txtInfo.setText(( lstInfo.getSelectedItem() ));
private void getTable() {
try {
String query = "SELECT FIRST, LAST, EMAIL FROM Names";
statement = databaseConnection.createStatement();
resultSet = statement.executeQuery( query );
while ( resultSet.next() ) {
lstInfo.add( resultSet.getString( "FIRST" ) + " " + resultSet.getString( "LAST") + " " +
resultSet.getString( "EMAIL" ) + "\n" );
statement.close();
catch ( Exception e ) {
System.err.println( e );
private void loadConnection() {
// define the data source for the driver
String sourceURL = "jdbc:odbc:people";
String username = "";
String password = "";
// load the driver
try {
// load the drive class
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
// create a connection through the drivermanager
databaseConnection = DriverManager.getConnection( sourceURL , username, password );
catch( ClassNotFoundException cnfe ) {
System.err.println( cnfe );
catch( SQLException sqle ) {
System.err.println( sqle );
public static void main(java.lang.String[] args) {
LabNine aLabNine = new LabNine( );
public void windowActivated(java.awt.event.WindowEvent e) {
public void windowClosed(java.awt.event.WindowEvent e) {
// closes the application
System.exit( 0 );
public void windowClosing(java.awt.event.WindowEvent e) {
// closes the application
System.exit( 0 ); -
How to print invoice (text based) from jspx/jsp ?
Hi All,
On our ADF Faces application , there is a requirement to print Invoice on a dot matrix printer from the application .
I can do that with Crystal XI but Java Report Component can only export to PDF or RTF, but the size of the report is too big for our narrow bandwidth.
So I am looking for a way to produced an Invoice to print in Text based. How can I do that ?
Thank you for your help,
xtantoHi,
Thank you.. I am downloading JasperReport & iReport now, two questions :
- Can JasperReport export to plain text file ?
- Is there any docs anywhere about JasperReport & JDeveloper integration ?
Thank you very much,
xtanto -
How to print a text file with pagebreak.......
hi to all,
i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.hi to all,
i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.
Maybe you are looking for
-
RE-printing a PDF book With Acrobat 9
I have this strange problem. When I print a pdf book as a pdf again (reason I am doing this if because it will give me a page size that will go with the entire book, and as a result, it will be easier to crop the book.), the file size becomes WAY big
-
I have just installed my new BTYV box. My previous BT Vision box had an rf output which allowd me to watch tv (the same channel) in another room (ive run a coaxial cable into my "room for making food" this forum will not allow me ty post the word kit
-
OUT OF MEMORY ERROR!!!! Please Help
In my program I have to store a large amount of objects and values into a hashtable (at least 500,000), but after only 400 values are stored I get the error: Exception in thread "main" java.lang.OutOfMemoryErrorCan you please help me with this, its v
-
Searching for Free Music in iTunes.
Is there a way to search for free music in the iTunes Music Store? Thanks Michael
-
I just bought a MBP with a 256 GB SSD. I know that SSD's have a limited number of writes. I often stream videos from Netflix, not download, just watch in-browser. It's not super high-definition, but it does say "HD." Does this add significantly to th