Is it possible generate file with line break without add one character?

Hi all,
my problem is when i generate a file .txt from ABAP as below:
"===>start of code<===
REPORT  zteste_bm.
TYPES: BEGIN OF ty_line,
         v_char(100) TYPE c,
       END OF ty_line.
DATA: v_it_final type table of ty_line with header line,
      wa_line type ty_line.
wa_line-v_char = 'line 1 with 24 positions#line 2 with 24 positions#line 3 with 24 positions'.
REPLACE ALL OCCURRENCES OF '#' IN wa_line-v_char WITH cl_abap_char_utilities=>cr_lf.
APPEND wa_line to v_it_final.
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = 'c:     emp     este.txt'
    filetype = 'ASC'
  TABLES
    data_tab = v_it_final.
"===>end of code<===
When i go to the file .txt it contains:
line 1 with 24 positions
line 2 with 24 positions
line 3 with 24 positions
and at the end of each line have a charactere in position 25 that represent CRLF (break line).
My problem is that character 25. I don´t have it in the file .txt.
Is it possible in ABAP use CRLF to generate the file .txt but remove them after generated? 
Thanks!

Bruno,
Check the paramteres of GUI_DOWNLOAD FM and observe how the text file is when you set or reset the hightlighted input paramters.
CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
*   bin_filesize                    =
  filename                        = g_dskpath
*   filetype                        = 'asc'
*   append                          = ' '
*   write_field_separator           = ' '
*   header                          = '00'
*   trunc_trailing_blanks           = ' '
  **write_lf                        = 'X'**
*  col_select                      = ' '
*   col_select_mask                 = ' '
*   dat_mode                        = ' '
*   confirm_overwrite               = ' '
*   no_auth_check                   = ' '
*   codepage                        = ' '
*   ignore_cerr                     = abap_true
*   replacement                     = '#'
*   write_bom                       = ' '
  *trunc_trailing_blanks_eol       = 'X' " X will delete the trailing spaces*
*   wk1_n_format                    = ' '
*   wk1_n_size                      = ' '
*   wk1_t_format                    = ' '
*   wk1_t_size                      = ' '
* importing
*   filelength                      =
TABLES
      data_tab                    = g_t_temp1[]
*   fieldnames                      =
EXCEPTIONS
file_write_error                = 1
no_batch                        = 2
gui_refuse_filetransfer         = 3
invalid_type                    = 4
no_authority                    = 5
unknown_error                   = 6
header_not_allowed              = 7
separator_not_allowed           = 8
filesize_not_allowed            = 9
header_too_long                 = 10
dp_error_create                 = 11
dp_error_send                   = 12
dp_error_write                  = 13
unknown_dp_error                = 14
access_denied                   = 15
dp_out_of_memory                = 16
disk_full                       = 17
dp_timeout                      = 18
file_not_found                  = 19
dataprovider_exception          = 20
control_flush_error             = 21
OTHERS                          = 22
if sy-subrc <> 0.
endif.

Similar Messages

  • Applescript batch convert DOC to TXT with line breaks

    Hey guys, I recently got stuck at work having to convert over 1,000 DOC files to TXT files with line breaks.
    I've found online several different Applescripts that work great at converting DOC files to TXT files but I can't find one that will do the TXT files with line breaks.
    If anyone has a script that can do this I would be crazy grateful.
    Converting these one by one with Word is taking forever to do.
    Thanks for any help you can give me.

    Excuse me for a moment for speaking harshly to you.  You are causing yourself utterly unnecessary headaches by not being clear with us and not stopping to think, and it's high time you learned that that is an incorrect way to approach anything on a computer.  Consider:
    you don't know what you're doing (in the sense that you don't know what 'text with line breaks' means)
    you don't know (or at least haven't explained) why this needs to be done
    (therefore) you don't know if this needs to be done at all
    (and yet) you are doing it anyway, in a mindlessly repetitive fashion, driving yourself batty and irritating me
    At least for the time being, humans are the ones who think and computers the ones who grunt away mindlessly; try to reverse those roles and everything gets done badly and slowly. Stop, look, think, plan ahead - that's what your brain is good at if you give it a chance.
    Now, as far as I can tell from poking around the web, 'text only with line breaks' means that the document  is saved as a plain-text file, but with a carriage return linefeed combination (CR/LF) as a paragraph delimiter (this is a Windows format - unix uses a single linefeed, Macs might use a single carriage return or a single linefeed). I don't know why anyone would want that format - most software will convert that seamlessly (or at least can be told to convert that).  Are you trying to feed this into some dinosaur of a database?  At any rate, if that's what you want, this script should do it. caution, this script overwrites the original files; I suggest you make a copy of one or two files in a separate folder, and run the script on them first to check that the output works for whatever reason you're doing this:
    set baseFolder to choose folder with prompt "Choose a folder of files to process"
    tell application "Finder"
              set fileList to (every file of baseFolder whose name extension is "txt") as alias list
    end tell
    repeat with thisFile in fileList
              set itsText to read thisFile
              if (offset of (return & linefeed) in itsText) = 0 then
      -- file is not already formatted with CR/LF, so convert
                        set itsChunks to tid(itsText, {return, linefeed})
                        set itsNewText to tid(itsChunks, return & linefeed)
                        set fp to open for access thisFile with write permission
                        set eof of fp to 0
      write itsNewText to fp as text
      close access fp
              end if
    end repeat
    on tid(input, delim)
      -- handler for text items conversions
              set {oldTID, my text item delimiters} to {my text item delimiters, delim}
              if class of input is list then
                        set output to input as text
              else
                        set output to text items of input
              end if
              set my text item delimiters to oldTID
              return output
    end tid

  • Webhelp forcefully generating files with lowercase filepath

    Hi,
    I have a list of APIs in the TOC that has the folder names in Sentence case;
    The TOC is somewhat like this:
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    -Product APIs
    ---xyz
    ------API documentation
    ---------foo
    ------------foo API1
    ------------foo API2
    ------------foo API2
    ------Webservices API documentation
    ---------Foo
    ------------FooAPI1
    ------------FooAPI2
    ------------FooAPI2
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    The path to an API in Foo in the auto-generated files, such as in whdata, should be: /product_apis/xyz/webservices/Foo.
    However, the path in the the auto-generated files changes to /product_apis/xyz/webservices/foo/
    (note 'Foo' changes to 'foo')
    Since Linux is case-sensitive, these API links do not work in Linux.
    I have replaced all such instances by using a search and replace tool.
    But this is only temporary.
    How do I make sure the files maintain the correct case of the filepath or foldernames
    Thanks and regards,
    PT

    Okay, got it.
    Thanks Rick!!
    I could figure out why the links are breaking by knowing that the filapaths are being generated in all lowercase; I got to know about this by examining the auto-generated files. That's about it.
    Thanks again
    On Wed, 28 Sep 2011 22:02:50 +0530  wrote
        Re: Webhelp forcefully generating files with lowercase filepath
        created by Captiv8r in WebHelp - View the full discussion
    Hello again In RoboHelp 7 if you examine the properties of your Single Source Layout recipe, look near the top of the first page of the dialog. There is where you see the option for lower case file names.  http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-3942922-84647/318-346/tmp1.PNG  Actually, this option is intended to PREVENT things from going haywire when you publish. When it's enabled, the process of generating WebHelp ensures all file names are lower case. But it also ensures all links are amended to lower case so it will prevent broken links from occurring. I'm confused as to your mention of what's inside the whdata, whgdata and whxdata files. These are auto generated by RoboHelp and there should never be a need to muck about with any of them. If you are, perhaps that's part of the issue?   Cheers... Rick    http://www.robowizard.com/pc.gif Helpful and Handy LinksRoboHelp Wish Form/Bug Reporting FormBegin learning RoboHelp HTML 7, 8 or 9 within
    the day!Adobe Certified RoboHelp HTML TrainingSorcerStone BlogRoboHelp eBooks
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/3942922#3942922
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/3942922#3942922. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in WebHelp by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How to avoid starting a page with line breaks?

    Hello. I've just started to refine my Master's thesis and some of the topics moved up and down as I edited their contents. The problem is that in some cases the topic breaks right after the title, and the rest of the contents just move away to another page. Is there any way to avoid starting a page with line breaks or broken topics?

    At the end of your title, you didn't inserted a line break but a paragraph break (carriage return).
    Acivate the mode "Show hidden characters"
    Select the carriage return (paragraph break)
    Delete it
    Press Shift + return to insert a true line break.
    It may be useful to apply that several times if you inserted several carriage returns between the title and the first filled line.
    Yvan KOENIG (VALLAURIS, France) 15 mai 2011 19:40:14

  • Oracle Apps RDF Report generates file with ^M (Carriage return) characters

    We are upgrading from 11i to r12 (also moving from HP unix to AIX on hardware side) and this rdf report generates a text file which is then eventually sent to a third party system for printing. Report works just fine in 11i as it generates a file without any ^M chars but in R12 environment, the same report generates file with ^M chars.
    Also want to understand how the Oracle Apps system hands over the output files to O/S which is saved.
    Pls advice
    Thanks
    Ram M.

    What type of concurrent program are we talk about here?
    This is a Report type of Concurrent program
    How does the text file get generated?
    Report is generating a Text file on :desname, a custom folder. 
    Was the binary mode used to copy the files from the old server to the new one?
    I believe RDF Reports were copied over in Binary format but none of the text files generated from old server are copied over.

  • Applescript batch convert .RTF to .TXT with line breaks

    Hey guys, looking for help with an Applescript that can change a .RTF to a .TXT with line breaks.
    I have an Applescript that will go from a .DOC to a plain .TXT but haven't found anything to get from the .RTF to a .TXT wth line breaks.
    I'm doing this for Avid's Script Sync.
    Thanks for the help.

    Ok, you obviously mean something specific by "line breaks" that you're not being clear about.  are you looking for a specific kind of line ending: Mac style carriage return (CR) ending? Windows style carriage return line feed (CR/LF) endings, unix style line feed (LF) endings?  textutil provides LF by default (it's a unix utility after all); if you need a different line ending you'll need to pipe it through tr or modify it via applescript after you've done the conversion

  • Re-post Replacing Hyphen with Line break

    Can someone please respond to the post: Replacing hyphen with line break
    Thanks.

    Please learn proper forum etiquette. Posts like this are (a) unnecessary and (b) actually quite annoying. At the very least, bump the original posting (but not, like, 30 minutes later because noone answered).

  • Replacing hyphen with line break

    Hi,
    In my application I want to replace the hyphen with line break
    . I am using APEX4.0
    I am using the following javascript code:
    <html>
    <script type="text/javascript">
    function test()
    var visitorName = "<br/>";
    var myOldString = "&P2_SI.";
    var myNewString = myOldString.replace(/-/g, visitorName);
    </script>
    </html>
    I have no clue how to get it executed and make the javascript work.... can someone help?

    My application is a online test.. One of the question in Page 3 is to re-arrange the sentence that is in the form of bullets. In the text area, as there are no formatting the candidate just gives hyphen - and enters all the sentences.. so in the DB the values are saved in the single line and when we evaluate the paper, it looks odd. So we want to replace the hyphen with the line break
    , so that when evaluating the paper, the format looks good, enter of one sentence there will be a line break.
    After the candidate is done with the Page 3, clickig next button, saves the values to the DB, and the page (branching) goes to Page 4 and clicking the Previous button takes the candidate to Page 2 (branching).
    The Dynamic Action is created in the following order
    -Advanced
    -action name
    -Event ->Change
    Selection Type->Item(s)
    Item(s)->P3_S2I
    Condition-> No condition
    -Action->Execute Javscriot code
    Disabled Fire on Page Load (as the code should execure only after the candidate type something in P3_S2I text area or after the Next button is clicked.
    Code:
    <script type="text/javascript">
    var special = "<br/>";
    var myOldString = "&P3_S2I.";
    var myNewString = myOldString.replace(/-/g, special);
    document.write("<br /> " + myNewString);
    </script>
    -Selection Type -> Item(s)
    Item - P3_S2I
    -Click Create
    This time I was taken to the next page.... but at the DB level hyphen is not replaced by the line break

  • How do I print to a postscript file with InDesign CS6 without both extensions, .indd.ps?

    How do I print to a postscript file without an .indd extension in InDesign CS6? I choose Print, choose a print preset from my print shop and Save. The first time I tried it was blank (the Hide Extension was checked), so I tried to save and got a dialog box that said it cannot be saved as an .indd file (duh), to choose both or .ps. I chose .ps and it was fine, but every time I postscripted it gave me this dialog box until I unchecked Hide Extension. After I did that, every time I postscript it automatically saves both extensions. Not a big deal but it is annoying. I just want it to end with .ps like it used to. Any ideas on how to fix this?
    Thanks!!

    I have no idea but I am incredibly curious...why are you doing this?
    Printing to postscript is a completely archaic workflow. Export to PDF
    instead.
    Bob
    TKnudt <mailto:[email protected]>
    Tuesday, January 15, 2013 6:12 PM
    >
          How do I print to a postscript file with InDesign CS6 without
          both extensions, .indd.ps?
    created by TKnudt <http://forums.adobe.com/people/TKnudt> in
    /InDesign/ - View the full discussion
    <http://forums.adobe.com/message/4996731#4996731

  • I downloaded CS6 Red Plug-In and added to Package Contents, replaced the current files with the new without backing up, now my RED footage thumbnails and color-correction don't WORK! How do I get my old importerRed file back!!?? HELP!

    I downloaded CS6 Red Plug-In and added to Package Contents, replaced the current files with the new without backing up, now my RED footage thumbnails and color-correction don't WORK! How do I get my old importerRed file back!!?? HELP!

    Try asking in the Premiere Pro  forum seems to be an Adobe Lab for Premiere Pro

  • Outbound interface - Generating files with ANSI encoding.

    Hi All,
    I am able to generate output files with txt extension. But it is generating in UTF-8 encoding files, myself when i open the files in notepad, i find UTF-8 and when opened in wordpad i find ANSI. My user wants it in ANSI in any case.
    One more thing my client's language is Spanish, where there will be special characters like Ñ, so if the file is in ANSI, will there be a problem for this characters.
    Please help.

    So which OS is to blame? The Mac seems to be inserting weird paragraph returns that Windows doesn't understand, no matter what type of file encoding you use (UTF-8, Western Windows Latin 1, Western DOS Latin 1).
    My understanding is that TextEdit uses standard Unix type line endings, called LF (line feed, hex 0A). Windows stuff uses a different convention, CR + LF (0D 0A). If a Windows app will not display text just because it encounters something other than CR + LF, I'd say it probably has a bug of some sort.
    Is there a solution to this probem?
    I don't think the line endings of TextEdit can be changed. Some other apps like Text Wrangler offer you a choice in their preferences.

  • Robohelp HTML 8 - Generating files with apostrophe in file name

    Before I start, I have read this thread
    http://forums.adobe.com/message/1062904#1062904 and several others, yet I still have questions.
    Previously I used Robohelp 5x, which worked perfectly.  Our user manuals are in MS Word and each have several topics that have apostrophes in the topic name (that are necessary in the topic).  Robohelp 5x would import the Word Document without issue and create HTML files that automatically replaced the apostrophe with an underscore.  All references (Index, TOC, etc) to those files also automatically changed to underscore.
    Fast Forward to Robohelp 8.0.2 (yes, I have the update).  Even if I go into the options and make sure "Use Underscores in file names" is selected - it no longer replaces the apostrophe with an underscore (though it does replace the spaces with underscores).
    Locally, when I generate the online help (WebHelp) and put it on our local webserver - it works just fine.  Even with the apostrophes in the file names and references.
    However, when the WebHelp files are hosted at our server hosting facility, any links within the Webhelp to files with an apostrophe result in a 404 error.  I have searched and searched to see if there is some kind of server setting to allow these special characters to be recognized in the file name but have not had any luck.
    Per the link at the beginning of this post, the issue in that thread was resolved by changing the file name of the HTML files.  I attempted to change the file name of the HTML files that RoboHelp created.  However as far as I can tell there is no way to do this within RoboHelp 8.  If I attempt to do it outside of RoboHelp 8, I need to import all of the "new" HTML files and all references (Table of Contents, Index, etc) now show broken links and need to be re-linked to this new topic.  This is not an option.  I have 12 user manuals that are updated on a regular basis and the renaming\relinking process would take forever.
    Any help would be greatly appreciated.
    Thanks,
    -Noob

    I was able to log into the server hosting facility and look at the html files themeslves.
    It appears that at some point (between when I created them locally and now) all of the apostrophes in the file names were changed to "Æ".  This blew my mind.  And sure enough if I plug in the URL and replace the apostrophe with "Æ" the page shows up just fine.
    From what I've been reading it looks like that may be related to the conversion from MS Word and "Smart Quotes".  I'm looking into that now, but any help would still be great.
    Thanks,
    -noob

  • Output with line breaks seemingly randomly placed

    Hola -
    I've adapted Tyler Muth's RSS feed article (http://tylermuth.wordpress.com/2008/01/22/producing-rss-from-plsql/) for the most part successfully; however, my output has breaks in the lines at inappropriate places, often in the mddle of an XML element tag for example. The placement of the breaks varies if I change the values of l_idx, l_len, l_defrows, l_maxrows, and l_desclen, but the breaks persist. They're not reflected in the code below but I've added the utl_file.fflush to no good effect.
    Examples of broken output:
    <pre>
    <title>Three
    prehistoric inventions that shaped us /</title>
    <guid
    isPermaLink="false">226402455778123622</guid>
    <pubDate>Thu, 04 Aug 2011 12:36:22
    EST</pubDate>
    <guid isPermaLink="fal
    se">220922455778123622</guid>
    <item
    >
    </pre>
    It's a lot of data so I won't post it here, but here's the code & the table; any ideas as to where to start investigating will be greatly appreciated.
    Code:
    create or replace
    PROCEDURE "RSSLOOP3" ( fund_in IN VARCHAR2, fund_in2 IN VARCHAR2 := 'XXX')
    is
    -- customizable parameters
    l_title varchar2(255) := ' New Titles Since ' || to_char(sysdate - 90, 'MM/DD/YYYY');
    l_link varchar2(255) := 'replace this' || fund_in || '.rss';
    l_description varchar2(255) := 'This is a feed of changes to items ' || fund_in;
    l_language varchar2(255) := 'en-us';
    -- end customizable parameters
    l_version varchar2(10) := '2.0';
    l_clob clob;
    l_idx pls_integer := 1;
    l_len pls_integer := 255;
    l_defrows pls_integer := 100;
    l_maxrows pls_integer := 100;
    l_desclen pls_integer := 250;
    -- for output to file
    fh UTL_FILE.FILE_TYPE;
    path VARCHAR2(30);
    filename VARCHAR2(30);
    begin
    path := '/http/live/screens/rss/';
    filename := fund_in || '.rss';
    fh := UTL_FILE.FOPEN(path, filename, 'w');
    for i in (
    select xmlelement( "rss",
    -- Begin XML Header Block
    xmlattributes( l_version as "version"),
    xmlelement( "channel",
    xmlforest( l_title as "title",
    l_link as "link",
    l_description as "description",
    l_language as "language"),
    -- End XML Header Block
    -- Begin List of Individual Articles or Items
    xmlagg(
    xmlelement( "item",
    xmlelement("title", x.title),
    xmlelement("link", x.link),
    xmlelement("description", convert(x.description, 'UTF8', 'AL32UTF8')),
    xmlelement("callnum", x.callnum),
    xmlelement("pubDate", to_char(x.updated_on,'Dy, DD Mon RRRR hh24:mi:ss')),
    xmlelement("guid", XMLATTRIBUTES('false' as "isPermaLink"),x.id||to_char(x.updated_on,'JHH24MISS'))
    -- End List of Individual Articles or Items
    ) as result
    from ( -- Actual Database Query that populates the list of Items
    select id,title,link,description,updated_on, callnum
    from drx_rss_feeds
    where (fund like fund_in||'%')
    and rownum < (l_maxrows+1)) x)
    loop
    l_clob := xmltype.extract(i.result,'/').getclobval;
    exit;
    end loop; --i
    --- OUTPUT RESULTS
    for i in 1..ceil(dbms_lob.getlength(l_clob)/l_len) loop
    UTL_FILE.PUT_LINE(fh,(substr(l_clob,l_idx,l_len)));
    l_idx := l_idx + l_len;
    end loop; --i
    UTL_FILE.FCLOSE(fh);
    end rssloop3;
    Table:
    CREATE TABLE "DRX_RSS_FEEDS"
    "ID" VARCHAR2(32 BYTE),
    "TITLE" VARCHAR2(255 BYTE),
    "DESCRIPTION" VARCHAR2(4000 BYTE),
    "LINK" VARCHAR2(1000 BYTE),
    "AUTHOR" VARCHAR2(255 BYTE),
    "UPDATED_ON" DATE,
    "CALLNUM" VARCHAR2(255 BYTE),
    "FUND" VARCHAR2(10 BYTE)
    )

    Or have a look at the Oracle Documentation, for instance at the parameters for utl_file.fopen
    max_linesize Maximum number of characters for each line, including the
    newline character, for this file (minimum value 1, maximum
    value 32767). If unspecified, Oracle supplies a default value of
    1024.It wouldn't surprise me if your randomly placed line breaks are all 1023 characters a part.
    Anton

  • Problems uploading a text file with line feed characters from Windows

    Hi,
    I am using the FM GUI_UPLOAD to load a text file in which at the end of each line there is a line feed character. When I upload the file, the FM interprets the entire file as ONE record; it does not recognize the line feed character at the end of each file line. I am using the parameter in the FM "HAS_FIELD_SEPARATOR" and it does not do anything to remidiate this issue.
    The funny thing is that  WS_upload works like a charm and it separates every line in the text file according to the line feed character at the end of each file line.
    Why a FM that is obsolete would work better and with  less effort than the new one? We are on 4.6c and will go to ECC6.0 May 2009.
    Can anybody recommenced a way to process this type of file using GUI_upload?
    The file to process is downloaded from a bank Website into a Windows PC. Sending the file to Unix first is not an option.
    Thanks,
    Pierre Martinez
    Edited by: Pierre Martinez on Aug 15, 2008 1:09 AM

    Hi,
    I have done that and Notepad does NOT interpret the line feed character. The file looks all messed up. Notepad does NOT split the data into records. The Hex character at the end of each file line is 0A.
    The user will download the file into a Windows desktop from the bank's website and from there an ABAP  program needs to read it and parse it. But the ABAP  program can not even catch the entire file with gui_upload. WS_upload can catch it with no issues.
    I tried catching the file into an internal table of data type string using GUI_upload, but it only catches two bytes of the file and nothing else.
    I will try catching the file in some other type of data type for the internal table in gui_upload.
    Once I catch it, I can split the file by the line feed character. I need to catch it  first, but "my glove" is not big enough. Defining the internal table for the gui_upload as character is a guessing game since I really do not know how big the text file is since GUI_upload will put it in a one record.
    Thanks.

  • Printing with line breaks

    Hi,
    I am using the following code to print some text from a text file.
    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import java.io.BufferedReader;
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.InputStreamReader;
    import java.text.*;
    public class Print implements Printable {
    private static final String mText = "";
    private static AttributedString mStyledText = new AttributedString(mText);
        static public void main() {
            String toPrint = "";
            try {
                FileInputStream fstream = new FileInputStream("/Library/iDemo/print.txt");
                DataInputStream in = new DataInputStream(fstream);
                BufferedReader br = new BufferedReader(new InputStreamReader(in));
                String strLine;
                while ((strLine = br.readLine()) != null) {
                    toPrint = toPrint + System.getProperty("line.separator") + strLine;
                in.close();
            } catch (Exception e)
                System.err.println("Error: " + e.getMessage());
            mStyledText = new AttributedString(toPrint);
            PrinterJob printerJob = PrinterJob.getPrinterJob();
    Book book = new Book();
    book.append(new Print(), new PageFormat());
    printerJob.setPageable(book);
    boolean doPrint = printerJob.printDialog();
    if (doPrint) {
    try {
    printerJob.print();
    } catch (PrinterException exception) {
    System.err.println("Printing error: " + exception);
    public int print(Graphics g, PageFormat format, int pageIndex)
    Graphics2D g2d = (Graphics2D) g;
    g2d.translate(format.getImageableX(), format.getImageableY());
    g2d.setPaint(Color.black);
            Point2D.Float pen = new Point2D.Float();
            AttributedCharacterIterator charIterator = mStyledText.getIterator();
            LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator, g2d.getFontRenderContext());
            float wrappingWidth = (float) format.getImageableWidth();
            while (measurer.getPosition() < charIterator.getEndIndex())
                TextLayout layout = measurer.nextLayout(wrappingWidth);
                pen.y += layout.getAscent();
                float dx = layout.isLeftToRight() ? 0 : (wrappingWidth - layout.getAdvance());
                layout.draw(g2d, pen.x + dx, pen.y);
                pen.y += layout.getDescent() + layout.getLeading();
            return Printable.PAGE_EXISTS;
    }The problem I am having is that it removes the line breaks when printing. I have checked the file I am reading from and that has the line breaks. How can I get it to include the line breaks?
    Thanks

    The problem is that once it prints all this the line break is gone.
    Up until the following code the line breaks are fine. However, the printed document I'm getting has no line breaks at all.
    mStyledText = new AttributedString(toPrint);
            PrinterJob printerJob = PrinterJob.getPrinterJob();
    Book book = new Book();
    book.append(new Print(), new PageFormat());
    printerJob.setPageable(book);
    boolean doPrint = printerJob.printDialog();
    if (doPrint) {
    try {
    printerJob.print();
    } catch (PrinterException exception) {
    System.err.println("Printing error: " + exception);
    public int print(Graphics g, PageFormat format, int pageIndex)
    Graphics2D g2d = (Graphics2D) g;
    g2d.translate(format.getImageableX(), format.getImageableY());
    g2d.setPaint(Color.black);
            Point2D.Float pen = new Point2D.Float();
            AttributedCharacterIterator charIterator = mStyledText.getIterator();
            LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator, g2d.getFontRenderContext());
            float wrappingWidth = (float) format.getImageableWidth();
            while (measurer.getPosition() < charIterator.getEndIndex())
                TextLayout layout = measurer.nextLayout(wrappingWidth);
                pen.y += layout.getAscent();
                float dx = layout.isLeftToRight() ? 0 : (wrappingWidth - layout.getAdvance());
                layout.draw(g2d, pen.x + dx, pen.y);
                pen.y += layout.getDescent() + layout.getLeading();
            return Printable.PAGE_EXISTS;
    }

Maybe you are looking for