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;
}

Similar Messages

  • How to print text/data in flex 3 using printer???Plz help...

       Hi,
              plz tell me the way to print text/data using printer in flex.  I tried the FlexPrintJob class. but it takes object of a container to be printed & prints the visible content of that container(along with scrollbars), bt i want to print all contents of the container(including invisible).
          I have tried to print bitmap image through FlexPrintJob but it takes lot of time for spooling... So plz help me out in printing(fast with all content) in flash
    I am using flex 3 (flex Builder 3 IDE).
      Thanks in advance!!!

    Hi Sagar,
    Don't worry You can use the below work around to print all the contents of the Container including the invisible contents under scrolll with out scroll bar..
    So what the idea here is we are seeting the container height to full size with out scrolls before sending the container object to printer and as soon as you print the object you are restoring it to the original height with scrolls...so that you can print the full contents without scrolls...
    You may have doubt that by chnaging and restoring the size the user may see momentary resize of the container but it is not so as it is a fraction of a second and user cannot notice this change... Give it a try ..I had already run into this problem recently and I have found a work around for this which is as below:
    // Here mainContainer is the container or box id the contents of which you want to print
       private function doPrintContainer():void
        var printJob:FlexPrintJob = new FlexPrintJob();
        if(printJob.start() != true) return;
        try
         var mainContainerHeight:int = mainContainer.height;
         //Increasing the height of the desired component to be printed.
         mainContainer.height = mainContainer.measuredMinHeight;
         mainContainer.verticalScrollPolicy = "off";
         //Adding the resized Component to our FlexPrintjob and then sending the print request
         printJob.addObject(this,FlexPrintJobScaleType.MATCH_WIDTH);    
         printJob.send();
         //Resizing the component back to normal size
         mainContainer.height = mainContainerHeight;
         mainContainer.verticalScrollPolicy = "auto";    
        catch(error:Error)
                     trace("Error : " + error.message);
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • Printing text at particular position in SAPscript

    Hi All,
    I want to print text at particular position, I used Command POSITION but it is not working .
    As I am using counter as Y position for a box and i want to print lines of text in that box. since I am able to position box according to counter but, texts which I want to display in box is not comming inside the box according to the counter.
    Please suggest what command to use for this.
    Thanks & Regards
    Shweta

    Yes Bernsen ,
    You are right. POSITION works only with BOX not with text.
    And also I can not create text in the another window  as there are two headers of main window in my form . one is for the line Items and after completion of it tis another header which is for the another lineitems say for withholding taxes of the vendor. so I need both the headers in the main window.
    Any way finally I got answer of my question. I will want to share with you all what I did:
    For the first box headre no y coordinate was required as height was the main thing here.
    Then came the line items . I set counter for this line item.
    This counter I used as ypos for the box. then for displaying heared text I made some adjustement with this counter as if line item is 2 then I gave one line space .
    whereas for multiple lines i.e. if no. of line is more than 2 then I gave 2 line space above the text to fit it into box. as my text was always appearing below drawn box.
    Thanks.
    Shweta

  • How to print text on container using oop on alv list

    Hello Guru's,
             pl guide me how to print text on container using alv list-display which have interactive events  using     oop classes/methods ...
                    I want to print hard coded text on coantainer , on double clicking it will call another screen.
    Pl Help..
    Message was edited by:
            paresh sonavane

    Hi Paresh,
           1.      Go to the Layout and Create One custom container box and give name it.
            2. Custom Container is the one type of tool and its used for Displaying the Reports 
                with the use of ABAP Objects.
            3. Go to se38 and Write The Following Code.
    tables ZTEAM_GD.
    DATA : OBJ TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
           OBJ1 TYPE REF TO CL_GUI_ALV_GRID.
    DATA IT_TEAM LIKE TABLE OF ZPLAYER_BAT_DET       .
    SELECT * FROM ZPLAYER_BAT_DET INTO TABLE IT_TEAM.
    CREATE OBJECT OBJ
      EXPORTING
        CONTAINER_NAME              = 'ALV'.          -
    > Give ur Container Name
    CREATE OBJECT OBJ1
      EXPORTING
        I_PARENT          = OBJ.
    CALL METHOD OBJ1->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        I_STRUCTURE_NAME              = 'ZPLAYER_BAT_DET'
      CHANGING
        IT_OUTTAB                     = IT_TEAM.
    *CALL METHOD OBJ1->SET_DROP_DOWN_TABLE
    EXPORTING
       I_STRUCTURE_NAME = 'ZTEAM_GD'
    CHANGING
       IT_OUTTAB        = IT_TEAM.
    CALL SCREEN 9000.
    *&      Module  USER_COMMAND_9000  INPUT
          text
    MODULE USER_COMMAND_9000 INPUT.
    CASE SY-UCOMM.
    WHEN 'EXT'.
      LEAVE PROGRAM.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9000  INPU     
    Thanks.
    Reward If Helpful.

  • How to print text rertrived by using the 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 module.
    its urgent. Points will be rewarded for any type of clue. whether it will work or not.

    loop the table into which u have retrieved the text .
    in the form interface of the smartform ... in importing parameter give the that table name .
    and in smartform whereever u want to print there insert the data into work area and pass to fields for dispaly .
    decalre ur work area in global defintions
    thnaks .

  • 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

  • Print jobs stuck in queue using P4015n LaserJet

    I setup a P4015n LaserJet printer for one of my clients using the RJ45 connection from the printer. My client has 4 computers 2 Windows 7 64 bit systems, 1 Windows 7 32 bit system and 1 Windows XP 32 bit system.  I set the network ip address, subnet mask and default gateway manually on the printer. Sometimes printing from the Windows 7 64 bit systems the jobs get stuck in the queue and you have to delete them before you can print again. The other 2 computers do not have any issues printing and they where setup using the drivers from the CD. I downloaded the latest PCL 6 drivers for the Windows 7 64 bit systems.  Looking for some suggestions.
    Thanks

    Ok the problem happened on one of the 32 bit computers so it is not a 64 bit issue.  Still looking for some suggestions.
    Thanks

  • Will not print text from PDFs - all other print is fine - Using nitro reader - Win7- HP4255

    Will not print text from PDFs - all other print is fine - Using nitro reader - Win7- HP4255

    Mulga
    Welcome to the HP Community Forum.
    Have you tried asking your question on the Nitro-Reader Forum?
    Nitro Reader Forum
    If you would like to try using the Adobe Reader, you might find help here:
    Manage Print Output with Print Preview
    See the section on PDF files
    Click the Kudos Thumbs-Up to show you appreciate the help.
    Click Accept as Solution when the Answer provides a Fix or Workaround!
    I am pleased to provide assistance on behalf of HP. I do not work for HP. 
    Kind Regards,
    Dragon-Fur

  • 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.

  • Use dot matrix printers for printing text reports in Reports 10g

    In Forms 6i, customers had the option to use dot matrix printers for printing text reports.
    I believe, from 9i onwards, text based reports aren’t supported and instead HTML/PDF,DOC,RTF reports are supported which are not text based and use modern day printers.
    Is it still possible to use text printers ??
    Regards,
    Noman

    hi
    check out the following link.
    Re: Is printing to generic text printer and hand-coding the report possible?
    http://download.oracle.com/docs/html/B10314_01/pbr_uxprt.htm#1005700
    sarah

  • HP D4260 printer how to print text on one side single 4.5 " by 5"post card using MSword

    How do I print text I have composed on a 4.5" by 5" post card using my HP D4260 printer and MS 200 word or another utility like open office?  If I could make the printer & software right justified so the card would feed thru the printer that might work but I am unable to do that.

    On my OJ Pro 8600, When I go to print a # 10 envelope, it feeds the envelope through and then prints the address on a letter page.  I was forced to set the printer preferences to #10 envelope, and within Word, set the paper type to # 10 envelope, set Word up for center feed, and then put everything back to print normally.  ON my 6500 all I had to do was hit print.  There must be a way to print single envelopes without jumping through all these hoops!!

  • Scanning Printed Text for use in TextEdit

    Is there a way to scan a printed document so it can be used as editable text?
    I need to bring printed typed letters into TextEdit.
    Thank you,
    Jesse Tyler

    Yes, for that you need Optical Character Recognition software, OCR for short. MacOS X does not have anything like that for scanned input, you need to buy commercial software.
    However, I recall that since Panther MacOS X carries a module called Inkwell, were you plugged in a Wacom Tablet and the system would be able to recognize what you hand-wrote. Never had a chance to try it since I don't have a tablet...

  • Print Text File in NW 3.12?

    I have to admit some ignorance regarding NetWare printing, so my
    apologies in advance...
    I work for a document management company, and am trying to find a
    solution for a customer running a fairly archaic, DOS 6.22-based
    application that utilizes a NetWare 3.12 server for file and print
    services. My need is to retrieve print output from their application,
    in the form of a text file, and then reprocess it for automated faxing
    through a fax server device.
    My problem is this: their application seems to print directly to a
    printer by defining what it calls a "network port" (which seems to map
    to a spooler, 0 through 5) or LPT1, and by referencing a printer
    definition. As far as I can tell, the files that are deposited in the
    print queue are byte streams, i.e., they're not human-readable (they
    have extra characters that I'm assuming are control characters). They
    therefore aren't usable by my print distribution software.
    I've tried using CAPTURE to send to a text file, but the application
    seems to conflict with the command. If I set CAPTURE, then start the
    application and send a job to LPT1, the application returns an error
    that the printer is unavailable. Upon exiting the application the port
    is no longer being captured (although I've tried all of the options I
    can think of to keep it so). Oddly enough, the application does
    successfully print a text file to LPT2 (for a barcode printer), which
    is CAPTUREd via a command in the system autoexec.bat. This is done a
    different part of the application.
    If anyone can help me figure out a way to generate a text file in this
    environment, or to work with the print file that's currently being sent
    to the queue (e.g, can it be translated somehow to a simple text file?),
    that would be much, much appreciated. This customer is in a tight spot,
    with an unsupported application that they can't presently afford to
    upgrade. My solution would save them enough money over time to replace
    the system.
    Again, thanks in advance for any help!
    wynand32

    If the Dos app has no print drivers included, then indeed it is relying
    on NW and PRINTDEF/PRINTCON to do the formatting stuff. That must have
    already been set up for it to be successfully printing now, it's just a
    matter of adding a definition that doesn't do anything to the print text.
    >In fact, given my ignorance of the NetWare environment, I'm not sure
    how the term "driver" even applies, unless it would refer to the
    printer definition.
    I was referring to a driver within the Dos app, nothing to do with
    NetWare. For instance Word Perfect for Dos came with Dos drivers for all
    sorts of printers, one of which was a generic text driver.
    >I wonder: is there a setting in PRINTDEF that could be changed for one
    of the printer configs that would influence the output? Or, would
    PRINTCON apply in this environment?
    Not supplied, AFAICS, but either one of the simpler print drivers
    supplied such as Diablo will do, or you'd need to set one up. Hopefully
    http://www.novell.com/documentation/...a/fm19724.html
    will help you enough as it's been too long since I did it to remember
    the details.
    Andrew C Taubman
    Novell Support Forums Volunteer SysOp
    http://support.novell.com/forums
    (Sorry, support is not provided via e-mail)
    Opinions expressed above are not
    necessarily those of Novell Inc.

  • Print text file to  client side printer

    Hi all,
    I have a character mode report which will print to a client side dot matrix printer in 6i. After converted to 10g, we cannot print to the client side printer (because we don't want to map so many print queue from the AS).
    So, I try to generate the report to a text file, then use webutil to transfer the txt file to the client PC, and then use Client_HOST to call the window PRINT command to print the text file to the client side printer.
    I have test this is successful, however, when I try to do the same thing to a report with Vietnam character, then it is not.
    The print request is sent to the printer, but the printer have no response.
    But that file can be print successfully if I open in Notepad and then print manually.
    I try to use window TYPE command and COPY command, but still have no luck.
    Can anyone give me some suggestions for this....
    Thanks!

    Qiu (guest) wrote:
    : In the browser/applet, the default "print" button can only
    print
    : screen to local printer, not the data I want. Use Report
    server,
    : I can't directly print to client side printer. Is there a way
    to
    : print data to local printer after press a button?
    Are u using Run_Product function in the when button pressed,
    then u can specify the format in which u want the output, option
    available are HTML and PDF, report server runs the report on the
    server and sends the output to the client machine. On the client
    machine u have to open the file and print it. I cannot print the
    report itself on the client machine.
    Try.
    Sailesh
    null

  • How can i print text messages from my htc amaze to my deskjet 3050A

    how can i print text messages from my htc amaze to my hp deskjet 3050A

    Hi,
    I believe the phone uses Android OS, v2.3.4 (Gingerbread) therefore you can use one of these applications:
       http://www.printeron.com/apps/androidprinting.html
       https://market.android.com/details?id=com.pauloslf​.cloudprint&hl=en
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

Maybe you are looking for

  • Save as PDF error in CS2

    Hello all, I've been researching this problem for a few days now, and trying all different output settings but to no avail. I haven't seen the issue described exactly like this so here we go. I have a design set at 150 DPI in CMYK, when trying to sav

  • Connecting USB Speakers to 2013 iMac without Airplay?

    Have new 27" iMac (Intel i5 May 2013 build) and find no way to hook up external USB speakers.  System's preferences offers no external opiton beyond Airplay which I hope to avoid.  I don't know the distinction between USB 2 and USB 3, but wonder if m

  • SXPG_COMMAND_EXECUTE failed for BRTOOLS - Reason

    Hi, My CI + DB in Suse Linux and SAP Karnal level is 159 My Dialog instace in on windows server and Karnal level is 159. When i trying to open the detail log of db13 from Dialog instace it was not opened and shows the error as below ( but it showing

  • Problem emptying Trash despite following every tip and trick I could find..

    Hi there, I have a small number of very large folders I can't delete from my Macbook, which I believe is caused by a problem with the external disk I originally copied them from. I had a problem with a disk because a colleague didn't eject it properl

  • Change the name of the universes in several reports

    Hi, We have thousands of DESKI reports which are pointed towards erroneous universes. I must make following tasks: 1- to change the name of each report. 2- In each report, to check out if there is only one or several data providers. 3- For each data