Printing text using jdk 1.4...only first character in string output

I have read way too many forum postings and still can't get simple ascii to come out my printer. Please don't point me to awt printing samples. I don't want the overhead/baggage of graphics contexts when they shouldn't be needed.
If I create a printer that's a file (set to generic/ascii), then after printing and giving a filename the file contents look ok. So, this seems to be a DocFlavor issue or something.
However when I try to print to a network printer (usb attached), I only get at best a single character on my page.
The following is tracing from my print method (shows text to be printed and doc flavors supported by printer):
PrinterImpl::print(text=hello world)
image/gif; class="[B"
image/gif; class="java.io.InputStream"
image/gif; class="java.net.URL"
image/jpeg; class="[B"
image/jpeg; class="java.io.InputStream"
image/jpeg; class="java.net.URL"
image/png; class="[B"
image/png; class="java.io.InputStream"
image/png; class="java.net.URL"
application/x-java-jvm-local-objectref; class="java.awt.print.Pageable"
application/x-java-jvm-local-objectref; class="java.awt.print.Printable"
application/octet-stream; class="[B"
application/octet-stream; class="java.net.URL"
application/octet-stream; class="java.io.InputStream"
It appears, that besides copious image printing support (why PNG and not TEXT?!?!?!?) I can print Printable's from the awt api, as well as byte arrays and input streams. I wish to not use the awt printing api.
I have tried all mentioned DocFlavors regarding BYTE_ARRAY.AUTOSENSE, etc. Nothing gives me more than a single character of output.
Any ideas? I'm getting a little burnt out on this problem.
Thanks.

I cannot comment on the 2 examples you referenced, because I don't have a Postscript printer, but your own example does not work, at least under Win2K, neither on a USB nor an ASCII printer, here is why (aside from the fact that it contains 2 or 3 formal errors).
I am trying desparately to print a simple ASCII file on a USB printer under Win2K since weeks and found 2 problems, but no solution so far.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Java PrintServiceLookup.lookupPrintServices() returns nothing
=============================================================
I want to print a simple ASCII file on a USB printer under Win2K and found 2 problems. Here is the 1st one.
PrintServiceLookup.lookupPrintServices(<DocFlavor>, <AttributeSet>) returns nothing when I specify any AttributeSet:
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
I tried
aset.add(new Copies(1));
or
aset.add(MediaSizeName.ISO_A4);
I tried it with JDK 1.4.2 and with Java 6, same problem.
When I specify null for AttributeSet, I get as many services as I have printers specified in the Printers folder of the Control panel.
I have scanned quite a few contributions about this subject, and it looks like this problem has been around since years, but I haven't found a solution.
But there is a circumvention of the problem for a parallel printer (at least an HP Laserjet 4 Plus): forget lookupPrintServices, just use the default printer. It works. Here are the essential code lines to print a simple ASCII file in Win2K.
//String fileID = = args[0];
FileInputStream textStream = new FileInputStream(fileID);
PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
DocFlavor myFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
DocPrintJob job = defService.createPrintJob();
Doc myDoc = new SimpleDoc(textStream, myFormat, null);
try {
job.print(myDoc, aset);
} catch (PrintException pe) {
System.out.println(pe.toString());
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Cannot print on a USB printer with Java PrintService
====================================================
I want to print a simple ASCII file on a USB printer under Win2K and
found 2 problems. Here is the 2nd one.
Even though
PrintServiceLookup.lookupPrintServices(<DocFlavor>, <AttributeSet>)
returns nothing when I specify any AttributeSet, I can still print on the default printer, which I get by
PrintService defServicedefService = PrintServiceLookup.lookupDefaultPrintService();
but only on a parallel printer (HP Laserjet 4 Plus), either directly attached or over the network. When I try the very same code on a locally USB-attached printer, the printer is obviously reacting, but nothing is printed.
In case of a Lexmark 730 (an ink printer), the driver even lies, it has printed 100%,
on a Samsung CLP-510 (a color laser) the ready light flashes twice, that's all.
The file to be printed has 5 lines and a "0C"X at the end in order to force a page eject at the end.
I tried it with JDK 1.4.2 and with Java 6, same problem.
I should mention that I can print that little file out of the editor Textpad without any problem.
Edited by: eSchobbert on Jan 30, 2008 7:26 AM
Sorry I forgot to mention, that this post refers to the pretty old post of MartinHilpert of May 22, 2003 2:45 AM

Similar Messages

  • Jpa native query returns only first character of a field

    Hi,
    I've a JPA native query that returns two fields from my oracle database. The first field is a CHAR(2) field with two char values in it, like 'OZ' etc.
    The problem is, as soon as the query is executed it returns only first character of field1. If the actual value of field1 is like 'OZ' then it returns only 'Z'.
    Query nativeQueryForProfileInfo = getManager().createNativeQuery(queryToRun);
    List list = nativeQueryForProfileInfo.getResultList();
    Please help,
    thanks

    There could be several explanations here and it's difficult to say without having more details, possibilities are
    There is something wrong with your display logic.
    There is something wrong with your mapping.

  • SO_NEW_DOCUMENT_ATT_SEND_API1 - attachment contains only first character

    Hi,
    we use the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send a report as txt attachment. The problem is that the attachment in the email contains only the first character of the origin text. But the atttachment in the transaction SOST has definitely more content (although not all as it should be... but this is another problem)
    Has anybody an idea what's wrong? We use ECC6. Before ECC6 we doesn't have that problem.
    Thanks and regards, Susanne
    Here is the content:
    DATA: begin of contents_bin occurs 0, "before ECC6
               line(132) type c,               
          end of contents_bin.
          t_contents_bin_soliti1 TYPE TABLE OF solisti1 WITH HEADER LINE. "with ECC6
        CLEAR t_pack.
        REFRESH t_pack.
    * Receiver:
        TRANSLATE p_output TO UPPER CASE.
        SELECT SINGLE * FROM ypruser INTO w_user
                        WHERE rusid = p_output.
        t_receiver-rec_id = w_user-rusid.
        t_receiver-receiver = w_user-email.
        t_receiver-rec_type = 'U'.
        APPEND t_receiver.
    * Document content:
    * Attachment content:
        CLEAR: wa_len, length, h_len.
        DESCRIBE TABLE contents_bin LINES lineno2.
        READ TABLE contents_bin INDEX lineno2 INTO wa_len.
        length = STRLEN( wa_len ).
        obj_descr = w_filename.
        t_pack-transf_bin = 'X'.
        t_pack-head_start = 1.
        t_pack-head_num = 1.
        t_pack-body_start = 1.
        t_pack-body_num = lineno2.
        t_pack-doc_size = ( ( lineno2 - 1 ) * 255 ) + length.
        t_pack-doc_type = 'TXT'.
        t_pack-obj_name = 'Attachment'.
        t_pack-obj_descr = obj_descr.
        t_pack-obj_langu = 'E'.
        APPEND t_pack.
    * Header data (fill table object_header):
        object_header = 'WP01_List.txt'.
        APPEND object_header.
        t_contents_bin_soliti1[] = contents_bin[]. "with ECC6
        w_commit_work = 'X'.
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
             EXPORTING
                  document_data              = document_data
                  put_in_outbox              = ' '
                  commit_work                = w_commit_work
             TABLES
                  packing_list               = t_pack
                  object_header              = object_header
                  contents_bin               = t_contents_bin_soliti1
                  contents_txt               = t_content
                  receivers                  = t_receiver
             EXCEPTIONS

    Thanks for your very helpful hint. So I saw that I could use the BCS cause we have ECC 6. This is much more easier. The txt attachment was then ok but the format of data was wrong. Finally I used these code line http://wiki.sdn.sap.com/wiki/display/Snippets/SendMailhavingMultipleFilesasAttachmentusingobjectorientedtechnique to solve it.

  • Only first character of plugin name is shown

    I'm developing a plugin using the Transmit API and for some reason it's only displaying the first character of the display name in the Playback window.
    The code is as follows:
    #define PLUGIN_DISPLAY_NAME L"My Plugin"
    memcpy(&outPluginInfo->outDisplayName, PLUGIN_DISPLAY_NAME, sizeof(PLUGIN_DISPLAY_NAME));
    I thought it could be because it's expecting a uint16_t array but the L macro produces a wchar_t array, however when I created a uint16_t array it still exhibited the same problem.
    It's worth noting that the example Transmit API code in the SDK suffers from this issue too.
    Currently my workaround is to not provide the outDisplayName at all which causes Premiere to populate it with the filename of the plugin bundle, but I would prefer to set the name programmatically.
    I am running Premiere Pro CS 6.0.2 on OS X 10.7.4.

    Thanks Zach, that now works with Encore but the problem with Prelude remains. The "stop" icon won't change to "play" and if I click it then it just steps forward by a single frame. I think for now I'll just disable the plugin in Prelude. This issue is reproducable with the sample code but if the Prelude team needs extra info I'm happy to provide it.
    Another issue I've found is that with certain types of footage (I've witnessed it with HDV thus far), every so often as I step through it jumps timecode numbers. So it will jump from 00:00:00:06 to 00:00:00:08 and then remain there for two frames before continuing on to 00:00:00:09 as normal.
    If I then log the frame time to the console, I can see that Premiere is saying that those two frames have the same time, even though they appear as distinct frames in Premiere.

  • Tree hierarchy of time displays only first character

    The Database is Teradata and I am using OBIEE 11g.
    I have time hierarchy and I have used this tree in reports. But when I drill down on the tree, only first letters of the caption are displayed not entire string.
    Eg: instead of Q1-2010, just Q gets displayed next to the + sign.
    If I drill on quarter, instead of showing "April", it shows "A".
    If I just display the column or the column is in form of the usual 10g drill down, then it is fine.
    Could anyone suggest a solution for this ?

    This happens to be a bug in obiee 11g. SR has been raised.

  • How to get the text field in the header for only first page of the report

    Hi,
    I am developing reports in BI Publisher Enterprise where i am facing problem i.e., i have to get some text field in header,for only first page in the result but it is displaying in all the other pages of the report in result.So,please if you have any idea of how to solve it, please reply.It is required as early as possible.
    Thanks in Advance

    Invalid path? What are you doing? Writing the report output to an invalid directory?
    Where are your terms and conditions? It would be very easy just to put them in a database table and select them in your report query.

  • How to print "Text" in JAVA(TM)....

    Does anyone know how to print "text" using Java?
    - Here's an example output...
    NOTE: # == 'empty spaces'
    --------------------------- <- Paper
    |###################|
    |####Welcome#########|
    |###################|
    |########to##########|
    |###########JAVA(TM)##|
    |###################|
    |#######Programming####|
    |###################|
    Please post a complete << SAMPLE CODE >> for printing the "text" (Welcome to JAVA(TM) Programming. Including the indentions. So it will not be like this...
    -------------------- <- Paper
    |Welcome |
    |to |
    |JAVA(TM) |
    |Programming |
    | |
    | |
    | |
    | |
    Thanks.

    Please read How To Ask Questions The Smart Way

  • How can we tell the printer to use a different paper cartridge

    Hello all,
    We are using t.code MN05 to assign a printer to each Purchase group. How can we tell the printer to use a different paper cartridge so that purchase orders ( output type ZNEU, ZEU, ZEN) can be printed on a paper with company logotype. Local team are removing most of the printers an we have only one multifunction printer availabel for a large number of employees.
    Thank you for your suggestions

    Hi,
    I can help you about how to use different Paper Tray's but different cartridge case I am not sure...

  • Only 1st character while fetching data through get_char_property

    Hi
    I am reading excel file through OLE2 object. while I am fatching data thr this utility It is fetching only first character of the string.
    procedure read_chr_cell( p_row number, p_col number, p_value in out varchar2 ) is
    args ole2.list_type;
    cell ole2.obj_type;
    begin
    args := ole2.create_arglist;
    ole2.add_arg(args, p_row );
    ole2.add_arg(args, p_col );
    cell := ole2.get_obj_property(worksheet,'Cells',args);
    ole2.destroy_arglist(args);
    p_value := ole2.get_char_property(cell,'Value'); [[[ PROBLEM AREA ]]]
    ole2.release_obj(cell);
    end;
    any advice is appreaciate
    Thanks
    Vishal

    Hi Vishal
    I think u need to LOOP Through the Records :)
    Hope this helps...
    Regards,
    Amatu Allah

  • First char of String

    How can I get the first character from a string? I was given the code below before but I do not think that it works correctly. If it does work then can more people please look at my previous thread and give me a hand.
    char firstNumber = inputString.charAt(0);         //first character of string
    char secondNumber = intputString.charAt(InputString.length()-1);    //last character of stringAs always, any help is greatly appreciated

    Apart from the obvious typos, it looks just fine to me. Why don't you think it works?

  • I am using window.print() to print the data of my webpage, it prints only first page and left the remaining while it works fine with IE and Google Chrome, ie print all the pages.

    My Page has data more than one page, it has verticle scroll bar to view all data .
    I used window.print() to print the data of webpage, but it prints only first page and left the remaining information.
    This works fine with Internet Explorer 6+ and Google Chrome.

    Does the entire webpage appear in Print Preview? <br />
    File > Print Preview

  • Can I use automatically select only first line of a caption to include in List of Figures?

    Is there a setting in the TOC utility in ID CS6 that will allow me to use only the first sentence in a caption to include in a list of Figures?
    Example
    Willard's Wharf, Cocoa, Florida, 1887.   This was Cocoa's first  blah blah blah.  Photo by a dead guy.  courtesy of a nice old lady whose grandmother collected it.
    In the example above, the entire passage is currently formatted using a paragraph style sheet in Arno Pro Caption.  When I'm done, I would like to have that first phrase or sentence in bold, which I planned to do with a character style sheet.  The remainder will be in regular type. 
    Now that I understand more how the TOC utility works, I'm wondering, can I make a paragraph style for the title phrase, and a second paragraph style for the remaining text in the caption that follows  If so, how to I ensure that the second paragraph will follow on the same line where ever the first paragraph style ends?  Nested styles, maybe?  If nested styles are the way to go, comments on or pointers to the simplest strategy to make this work will be appreciated.
    Captions are not consistent.  Some have a name and date; others are a Title phrase or sentence, followed, sometimes, by up to several sentences.  Typically, however, there is only one sentence after the title. I also usually have a "Courtesy of . . ." statement acknowledging the source of the photo.
    I'm a newbie using id cs6, for the first time, to format a book.  I'm enjoying using the program, but a few details sometimes bring me to a stop.
    Thanks
    Roy

    Roy,
    In fact, you only need a char style to control that you correctly mark what you want in the LOF.
    See how I do:
    1/ I create the para style "Caption" [color: Red] and insert a grep style in it.
    2/ I create the char style "Char_Caption" [color: Blue]. It only needs to control what I want in the LOF.
    3/ What I have to do is insert a "N-Joiner" in the "Caption" text. See the grep code of the grep style defined in the "Caption" para style.
    4/ I generate the TOC, only with the "Caption" para style. I select the story where I insert the TOC and launch this simple regex.
    Done! 

  • Am using hp deskjet 1050 series...am not able to print text in black ,why?

    hie....am using the hp deskjet 1050 printer and scanner ....ealier i was able to print all kind of text(black and color)....but now am unable to print text in black....why is it so?

    Hi,
    Please go to HP Printer Assistant (you can see this in Start Menu->HP->HP 3540 Series).Select 'Set Preferences'.Go to Layout tab and select Advanced tab. Go to Document Options and select 'Black Ink Only' (for black prints only).
    Colour Only doesnot makes sense. If you want to print the colour,just reset the above option.
    By default, HP printer prints black area with black and color with color.
    Hope this helps.

  • Printing text to an NT queue using 1.4 SDK.

    Does anyone have some code for printing text to an NT queue.
    I am particlarly interested in the MIME type and the print attribute sets used.
    The same exercise through JDK 1.2 generates a rastered image..
    An example would be greatly appreciated.

    This sample is for printing a gif in c:\temp\test.gif -> windows OS
    But you can also print text ...
    import java.io.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    public class PrintGif {
    public static void main(String args[]) {
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.ISO_A4);
    aset.add(new Copies(1));
    PrintService[] pservices =
    PrintServiceLookup.lookupPrintServices(flavor, aset);
    if (pservices.length > 0) {
    DocPrintJob printJob = pservices[0].createPrintJob();
    Doc doc = new InputStreamDoc("c:\\temp\\test.gif", flavor);
    try {
    printJob.print(doc, aset);
    } catch (PrintException e) {
    System.err.println(e);
    } else {
    System.err.println("No suitable printers");
    System.out.println("done.");
    class InputStreamDoc implements Doc {
    private String filename;
    private DocFlavor docFlavor;
    private InputStream stream;
    public InputStreamDoc(String name, DocFlavor flavor) {
    filename = name;
    docFlavor = flavor;
    public DocFlavor getDocFlavor() {
    return docFlavor;
    public DocAttributeSet getAttributes() {
    return null;
    public Object getPrintData() throws IOException {
    return getStreamForBytes();
    public java.io.Reader getReaderForText() throws java.io.IOException {
    return null;
    public InputStream getStreamForBytes() throws IOException {
    synchronized(this) {
    if (stream == null) {
    stream = new FileInputStream(filename);
    return stream;
    }

  • Only first bookmark will print

    I have combined a number of small PDF files into one. Each former individual file is represented as a bookmark in the combined file. However if a user tries to print the pages of the second, fourth and tenth bookmarks from the combined file, only the pages from the first bookmark will print.
    Any suggestions as how to fix this problem would be appreciated.

    You stated "As with earlier versions, Firefox 3.6.12 does not allow Print Previewing of any website content beyond first page". That isn't true from what I have seen when trying to print web pages myself. My experience has been as I stated, like maybe 5%. I'm not trying to push you to use Firefox when you are having these problems with printing. I'm just trying to let you know that these problems have been around for a long time, and I don't think a fix is coming any time soon.
    No, it's not "code protection". I don't think any of the developers have the talents to fix what's wrong with printing in the core code. Plus, print related Bugs never seem to have any priority attached, along the lines of "this is important and as the developer in charge of this module, I say it should be fixed before release the next major version. Let's make this a high priority and get it fixed ASAP". Then before they know it, that Bug is forgotten about as of being any priority to fix and 8 years passes.
    If you are interested in reading some of these print Bugs, see this search of Buzilla - 2479 Bugs related to "Print". Keep in mind that Bugzilla is for all Mozilla products, not only Firefox. So many of those Bugs are for products like SeaMonkey and Thunderbird, or the Gecko core that is part of all Mozilla products.<br />
    https://bugzilla.mozilla.org/buglist.cgi?quicksearch=Print
    If you see any Bugs that affect you, register for Bugzilla and '''vote''' for those Bugs. Unless you can offer a "fix", please don't make any comments in those Bugs. I sometimes think that some Bugs don't get fixed in a timely manner due to all the "spam" in the Bug report, by way of angry comments, which wastes time which could be spent writing code to fix the Bug. It ain't a discussion forum for users to rant about the individual Bug.

Maybe you are looking for

  • Is there a way to change the font size in the music app?

    Itouch 2nd gen user. just updated to 4.2 from 3.1.3, and boy does it suck. the font in the music app is so small now, i can barely see the song names and they take more care to hit, thus making it dangerous in the car. is there a way to fix what appl

  • How to populate the application server data on screen

    Hi.. In my present requirement... I need to give the vehicle no field on my custom screen...then i will press the capture weight button.... then it needs to fetch the weight from app server file (columns in file...1.date 2.time 3.weight...4.key.)and

  • TS3276 sent emails are in draft

    Bear with me I am new to the community and not particularily tech saavy. On occassion copies of sent emails are finding their way into my Draft folder. What am I doing wrong? Thanks for your help.

  • 10.4.8 AFP a reliable solution?

    Hi, I followed the discussions of the various AFP problems of Tiger Server while keeping my decision to use it for file service on hold. Is someone using 10.4.8 and can confirm that the problems were solved by that update (as the release notes promis

  • Satellite Logon

    Hello all, I hope someone can help me with this one. I am currently not able to logon to the DEV system from SolMan after setting an urgent request to "In development". If I use the transaction SM59, I am able to logon to the system through the RFC A