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.

Similar Messages

  • 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 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 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 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 poll a text file with lab view

    I am runnig a soft real time data collecting system for shop floor data collecting.reading serial port to list down data into text file. what is the best way of getting this data into labview?.polling of text file or some easy and quick method??

    1.) If the data is coming in separate files, use the 'List directory' function to find out when a new file arrives. Then just read it using one of the standard functions, (i.e. Read txt file.)
    2.) IF the data is being appended to a single file, use Open/Read/Close file functions. The read function will give you an offset value which tells you how far into the file you have read. Put that value in a shift register and then you can start reading where you left off when the file is updated.
    I hope this helps.
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal

  • How to create a text file with data.

    Hi,
    I am writing java code for testing an application, some times test can failed in some cases, I want to display an error message in text file. To that I written the code as like,
    BufferedWriter bout;
    bout =new BufferedWriter(new FileWriter("test.txt"));
    String str=”Your input data is not match with pattern”
    bout.write(str);but here it is creating a text file “ test” without any data in it.
    Can any body help that to execute the program properly
    Regards
    Buntty

    sabre150 wrote:
    JoachimSauer wrote:
    You didn't close your BufferedWriter. Since it's buffered it probably didn't write anything to the underlying file.
    Generally you must close every Writer/OutputStream that you no longer use or it won't be written reliably.It's not quite as simple as that. If you have a chain of Writers / OutputStreams then you only have to close() the outer most one since each is responsible for closing any Writer/OutputStream that it wraps. If you do decide to close them individually (a bad idea but people do do it) then you MUST close them starting from the outer most one and working to the most inner one or you will not guarantee to flush any buffered content.Of course. I might have used a misleading phrasing here. What I meant is "Every time you are done with a Writer, you must close it" and not "You must close *every* Writer that you used". Thanks for the clarification.

  • How to print html text created with HTML Editor Standard?

    I would like to print the text I added with the HTML Editor Standard, using advanced printing. I have made up a Word document with a Report Query and a Report Layout, but the text pops up as html text. Also when I use HTML as output the text shows as "p strong hallo /strong /p" (but then with < and >) instead of hallo . I understand what goes wrong, but I am unable to solve it. Is there a way to work around this?
    Thanks a lot, Frits
    Edited by: user3829016 on 10-nov-2009 5:51
    Edited by: user3829016 on 10-nov-2009 5:52
    Edited by: user3829016 on 10-nov-2009 5:53

    Thanks Lilly a lot!
    I forgot about this tag. It helps in my situation.
    P.S. I tried to solve problem with help of tag <pre> in such way:
    some_word<pre>     </pre>some_wordBut it didn`t helped.
    Thank you again

  • How to generate a text file with values from internal table

    hi,
    can anybody help me out to get the values from different internal table written into a text file.
    regs,
    raja

    used gui_download,ws_download,cl_gui_file_save.
    data: ld_filename type string ;
    ld_filename = 'c:\demo.txt'.
    DATA: begin of it_datatab occurs 0,
    row(500) type c,
    end of it_datatab.
    HII
    call function 'GUI_DOWNLOAD'
    exporting
    filename = ld_filename
    filetype = 'ASC'
    tables
    data_tab = it_datatab[]
    exceptions
    file_open_error = 1
    file_write_error = 2
    others = 3.
    gui_download

  • How to open a text-file with notepad from labview-vi?

    Hello,
    how can i execute a program from a vi?
    I want to open a textfile with Windows7-Notepad after selelecting it from a file-path-control and pressing an open-button.
    Thx for help
    Solved!
    Go to Solution.

    Use the command line.  Something like cmd /c notepad c:\temp\blah.txt should work.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Printing different/selective files with different copies

    Hi everyone,
    I've been working on finding a solution, on how to print different pdf files with different copies, without opening the pdf-files.
    Task:
    I have a folder, with 25 pdf files
    I want to make a php overview, of the folder
    At the end of each line/file - i would like to add a number for the copies
    In the end, I would like to simply press print - and every document ive added a number/copies to - are being printet...
    I guess I need to use PrintPDF - but does anyone know any pre-made program/function - that could handle the "copies" part...?
    I hope someone can help me out,
    Thanks
    Jan

    Well, i had hoped that the acrobat could open silent - eventhough they've removed that feature in the newer versions.
    Even though the program would open - if the amount of copies was added - and i just hat to press print - it would ease the job alot.

  • How to send a text file to a printer?

    Hi, I'm in dark on how to send a text file to a printer through Java Stored Procedure.
    Here are what I tried so far (OS: win 2000, Oracle: 817 or 9i2):
    1, Enable DOS command in Java Stored Proc. and try to send PRINT command there:
    public static String Run(String Command){
    try{
    Runtime.getRuntime().exec(Command);
    System.out.println("Command: " + Command);
    return("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    public static void main(String args[]){
    if (args.length == 1)
    Run("print /D:\\\\enterprise\\john " + args[0]);
    else System.out.println("Usage: java OSCommand filename");
    PL/SQL wrapper:
    CREATE OR REPLACE FUNCTION OSCommand_Run(p1 IN VARCHAR2) RETURN VARCHAR2 AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'OSCommand.Run(java.lang.String) return java.lang.String';
    SQL command:
    //print /D:\\machine\printer test.txt
    I loaded the Java Stored Procedure into SYSDBS account, it failed silently, even though piece of code works fine in external JVM.
    2, Use filePrinter:
    public static String print(String printString) {
    try{
    String printerUNC = "\\\\machine\\printer";
    FileWriter fw = new FileWriter(printerUNC);
    PrintWriter pw = new PrintWriter(fw);
    pw.println(printString);
    fw.close();
    return "OK";
    }catch(Exception e){
    e.printStackTrace();
    return "Exception: " + e.getMessage();
    public static void main(String[] args) {
    try{
    String printerUNC = "\\\\machine\\printer";
    String printString = "Hello World";
    FileWriter fw = new FileWriter(printerUNC);
    PrintWriter pw = new PrintWriter(fw);
    pw.println(printString);
    fw.close();
    }catch(Exception e){e.printStackTrace();}
    I loaded it into SYSDBS too, and tried with this:
    SQL> select MY_PRINT.PRINT('HELLO from Oracle') from dual;
    MY_PRINT.PRINT('HELLOFROMORACLE')
    Exception: No such file or directory
    SQL> show user
    USER is "SYS"
    It works in external JVM too.
    What's wrong with this?
    Thanks for any help in advance,
    Charles

    Avi:
    Thanks for your response!
    I put the java code in SYS, 'cause I assume that account has max privilege. If the test is successful, I will move that to some user schema and then to deal with those privilege settings... But I'm unlucky.
    I checked Ask Tom, this is what I got from http://asktom.oracle.com/pls/ask/f?p=4950:8:1619723::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:38012348052,%7Bprinter%7D:
    ... Print file from PL/SQL ...
    If you are using Oracle8i, release 8.1 -- much can be done with Java. java
    would be able to print directly from the server.
    Looks like using Java to print out file is better than PL/SQL. But there's no more hint there! And, no new question can be asked there today either...
    I'm wondering whether we can create a socket to a printer and send the characters there directly... Anyone has experience on this?
    Thanks for all the help in advance,
    Charles

  • How to create PDF from text file with specific layout?

    I wanted to create the pdf from text file in specific layout - Landscape orientation and JIS B3 Page size while at Adobe Acrobat Pro.
    In past, I could do a right click on a text file (desktop area) and select print to print out the document into .pdf BUT only if I set the Adobe PDF to Landscape and JIS B3 Page size BEFORE.  And I could only do 15 text documents at once.
    I wanted to see if I could do the create the pdf from text file with specific layout in Adobe Acrobat without having to go to Control Panel to preset the Adobe PDF to specific layout at every time.   I would have to set Adobe PDF back to normal layout after I'm done with these pdf print outs.  I do lots of pdfs in normal layout.  Sometimes I would forget to do that.
    So, How do I do that?

    No such luck.  It would output the contents in letter size even in JIS B3 Page layout at MS word. 
    Is there a script or action where I could set the orientation and page size before creating PDF on these text files?

  • How copy just line in text file with cat? (SOLVED)

    Hi.
    How i make to copy just only line in text file with cat?
    For example:
    [:0.0]
    file=/home/Arch/./.wallpaper.png
    mode=0
    bgcolor=# 0 0 0
    I want copy just "/home/Arch/./.wallpaper.png" part.
    Actually i want create a shortcut for last wallpaper set from Nitroget, then i put this in SLim background.
    Recently i use hsetroot for wallpaper (~/.wallpaper.png) and i create a shortcut in /usr/share/slim/theme/MYTHEME whith ln -s ~/.wallpaper.png /usr/share/slim/theme/MYTHEME/background.png.
    I want make a same with Nitrogen.
    I now this looks like crazy, but...
    Sorry my English.
    Last edited by kramerxiita (2008-06-04 16:50:48)

    moljac024 wrote:
    kramerxiita wrote:
    moljac024 wrote:How can you make SliM change the background ? You link the theme background to another file ?
    Yes. In theme directory i put background.png shortcut for my wallpaper. So, when a change wallpaper, slim background change too.
    Example:
    ln -s mywallpaper.png /usr/share/slim/themes/default/background.png
    So, Slim background always is my wallpaper.
    So the wallpaper has to be a *.png ?
    No, jpg is possible. But when you create a symbolic link, remember put the extension too. If change png to jpg, change a symbolic link extension.
    But, remember if slim theme directory have background.png and background.jpg, Slim always choice .png. So, put only one this.

  • How to print a pdf file of compounds A3 and A4 with adobe mac

    how to print a pdf file of compounds A3 and A4 with adobe mac, windows with the option I choose paper source by PDF page size mac but I can not find it. how to get it thank you

    I think if you use the start-command, the execution is asynchronously and you won't get the correct process-id. Try to execute Acorbat directly without the cmd /c start in front of it.

Maybe you are looking for