Turn off banner within Java Print Service API

I have web services running on JBoss 4.0.5, which is running on IBM AIX 5.
The issue I have is anytime I try to print something through Java Print Service within web services, there is always a banner, even though banner property is set to "never" on the print queue with AIX smitty. The bad news is that property value can be overwritten by applications, or by command line options with lp or lpr commands.
Couldn't find any way or any attribute avaiable in Print Service API to diable banner printing. Currently only default attributes are used in document printing.
Any help would be greatly appriciated!

fermar84 wrote:
Thanks for answering,
Yes i totally agree with you. There is a per device basis. However you could think (and here i am letting my imagination fly) about categorizing devices, lets say all the digital cameras. Although it would still be per-device basis, some would have common commands like turn on, or turn off. Don't you think so?
Now lets take a simple example, can a Java program turn off the computer where its running?
Thanks in advance,
FernandoDo I think all digital cameras expose an "on/off" API? No, I don't. Some may, they all may, but that's in no way a Java issue.
Can a Java program turn off a PC? No. It can call native code to do so, but then it isn't Java doing the work. All of what you're talking about is very much platform-specific, and that's where Java is generally it's weakest

Similar Messages

  • Java Print Service API in Java Stored Procedure (Linux)

    Hi
    We are running an Oracle 10g database on Linux and I am in the proces of developing a java stored procedure which should utilize the Java Print Service API.
    I have made a simple stored procedure to list all available printers and the DocFlavors they support (se the code below).
    My problem is that no printers are listed. I have made a standalone java app. with the same code and executed it directly on the OS level of the Linux box through the Sun JDK 1.4.2 and here I get two printers.
    Is there any specific configuration I need to do to make it work?
    I am wondering if I need to grant specific authorisations through dbms_java for it to work...?
    Any help is greatlyh appreciated.
    ************************************** CODE BEGIN *************************************
    import javax.print.DocFlavor;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    public class TestPrintService {
    public TestPrintService() {
    public static void listPrinters() {
    // Get all available printers and their supported DocFlavors
    PrintService[] pservices =
    PrintServiceLookup.lookupPrintServices(null, null);
    System.out.println("Printer services: " + pservices.length);
    for (int i = 0; i < pservices.length; i++) {
    PrintService pservice = pservices;
    System.err.println("Printer: " + pservice);
    DocFlavor[] docFlavors = pservice.getSupportedDocFlavors();
    for (int j = 0; j < docFlavors.length; j++) {
    DocFlavor docFlavor = docFlavors[j];
    System.err.println("DocFlavor " + docFlavor.toString());
    System.err.println();
    ************************************** CODE END *************************************
    Cheers,
    Jacob Vennervald

    Found this on Oracle support:
    Cannot List Available Printers From The Database Using A Java Stored Procedure [ID 372694.1]
    Applies to:
    Oracle Server - Enterprise Edition - Version: 10.1.0.4.0
    This problem can occur on any platform.
    Symptoms
    Able to list available printers on a machine when running Java code outside the Database.
    When running the same Java code inside the Database as a Java Stored Procedure, no printers are found.
    Cause
    Due to security restrictions, this is expected results.
    The Java Docs state:
    "Services which are registered by registerService(PrintService) will not be included in lookup
    results if a security manager is installed and its CheckPrintJobAccess() method denies access."
    Also from the documentation it states:
    "A PrintServiceLookup implementor is recommended to check for the SecurityManager.checkPrintJobAccess() to deny access to untrusted code. Following this recommended policy means that untrusted code may not be able to locate any print services. Downloaded applets are the most common example of untrusted code."
    Using the checkPrintJobAccess(); call, it does produce a Security Exception when run inside the Database but not when run outside. The exception can be viewed within the log file found in the UDUMP directory.
    Solution
    Run the following code to confirm obtaining available __printers can not be done...__
    This is the code to create the Java Stored Procedure
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "ListPrinters" AS
    import javax.print.*;
    public class ListPrinters {
    public static String AvailablePrinters(){
    String strList;
    PrintService[] pservices =PrintServiceLookup.lookupPrintServices(null,null);
    if (pservices.length > 0 )
    strList = pservices[0].getName();
    else
    strList = "No printers found";
    return strList;
    public static String listprinters() throws Exception {
    String listofprinters;
    try {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) sm.checkPrintJobAccess();
    catch (SecurityException ex) {
    System.err.println("Sorry. Printing is not allowed.");
    listofprinters = AvailablePrinters();
    return listofprinters;
    This is the PL/SQL Wrapper
    CREATE OR REPLACE FUNCTION Get_Printer_Test RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'ListPrinters.listprinters() return String';
    This executes the code
    SQL> SELECT Get_Printer_Test FROM DUAL;
    GET_PRINTER_TEST
    No printers found
    This is the output found in the trace file in the UDUMP directory
    *** SESSION ID:(144.28) 2006-07-08 09:02:25.518
    Sorry. Printing is not allowed.

  • Printing chinese w/ Java Print Service API become garbled characters

    I'm using XP platform and I've a plain text file on my drive.
    Now, what I want to do is, to read the text file in, then print it, that's all.
    However, the printout become messy, just some garbled characters.
    I did try to change quite a different ways to read the file, but the printout is still messy.
    Is there anything wrong? Can somebody give me a help?
    package com.ysf.document.client.ups;
    import java.io.FileReader;
    import java.io.IOException;
    import javax.print.*;
    import javax.print.attribute.*;
    public class Class1
       public static void main(String[] args)
          String filename = "c:\\temp\\abcd.txt";
          DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
          PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
          // locate a print service that can handle it
          PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);
          // create a print job for the chosen service
          int printnbr = 1;
          DocPrintJob pj = pservices[printnbr].createPrintJob();
          try
             int c;
             FileReader f = new FileReader(filename);
             StringBuffer buffer = new StringBuffer();
             c = f.read();
             while (c != -1)
                buffer.append((char) c);
                c = f.read();
             Doc doc = new SimpleDoc(buffer.toString().getBytes("BIG5"), flavor, null);
             pj.print(doc, aset);
          } catch (IOException ie)
             System.err.println(ie);
          } catch (PrintException e)
             System.err.println(e);
    }

    For #1, indeed, it's my overlook, I've corrected it already.
    For #2, it shows, java.lang.ArrayIndexOutOfBoundsException: 1.
    It's mainly because my printer do not support this flavor.
    My printer supports only:
    image/gif
    [B OR java.io.InputStream OR java.net.URL
    image/jpeg
    [B OR java.io.InputStream java.net.URL
    image/png
    [B OR java.io.InputStream OR java.net.URL
    application/x-java-jvm-local-objectref
    java.awt.print.Pageable OR java.awt.print.Printable
    application/octet-stream
    [B OR java.net.URL OR java.io.InputStream
    Up to now, still no solution to it. Anybody help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Urgent java print service API ?

    Hi all,
    I would like to use javax.print.*;
    libraries but I am using jdk1.3.1, I think in jdk1.3.1
    there is no javax.print.*; libraries , so how can I download the
    only java print API from jdk1.4..
    if anyone knows please help me..
    thanks

    You can't. You must upgrade your SDK to 1.4

  • Successful using Java Print Service API on Windows 32 Platform

    Hello,
    Using the JSP API supplied with JDK1.4, I was able to print successfully the following types of documents :
    1. Text
    2. GIF, JPG... (images)
    3. PostScript files.
    But could not print "HTML" files. THe problem is that the HTML files are getting printed as text files with all the HTML tags.
    Any pointers are appreciated.
    Thanks
    TJ

    You will need to load the html into something that can render html. The printer doesn't know how to do it. It just sees plain text that you are sending. Try using JTextPane or JEditorPane (I think). It can render html files for you. Then just print that component.
    1) Create JEditorPane or JTextPane.
    2) Set contents of pane as the html file or string you want to print.
    3) Use the Graphics2D API to adjust the component coordinate space to the printer coordinate space.
    4) Render the component (JEditorPane or JTextPane) on the printer.
    There is a very nice tutorial for printing components here: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html.
    Hope this helps.

  • Does java print service support word docs or text files

    Can anyone tell me that java print service api allows to print word doc files or RTF files etc.

    no it doesn't.
    To print a Word Doc you need to be able to read it, and display it.
    Anything that can be displayed in, say a JPanel, can be printed, cos it's just a matter of displaying the
    image to a virtual component ( a print canvas ). Which then gets printed.
    So, because Java doesn't immediately support Ms Docs, neither does the print service.
    regards,
    Owen

  • Printing HTML with Java Printing Service(JDK1.4 beta)

    Hi there!
    I'm currently checking out the new Java Printing Service (JPS) in the new JDK1.4 beta. This looks like a very promising printing API, with amongst others printer discovery and support for MIME types - but I have some problems with printing HTML displayed in a JEditorPane.
    I'm developing an application that should let the user edit a (HTML)document displayed in a JEditorPane and the print this document to a printer. I have understood that this should be peace-of-cake using the JPS which has pre-defined HTML DocFlavor amongst others, in fact here is what Eric Armstrong says on Javaworld (http://www.javaworld.com/javaone01/j1-01-coolapis.html):
    "With JPS, data formats are specified using MIME types, for example: image/jpeg, text/plain, and text/html. Even better, the API includes a formatting engine that understands HTML, and an engine that, given a document that implements the Printable or Pageable interface, generates PostScript. The HTML formatting engine looks particularly valuable given the prevalence of XML data storage. You only need to set up an XSLT (eXtensible Stylesheet Language Transformation) stylesheet, use it to convert the XML data to HTML, and send the result to the printer."
    After one week of reasearch I have not been able to do what Armstrong describes; print a String that contains text of MIME type text/html.
    I have checked the supported MIMI types of the Print Service returned by PrintServiceLookup.lookupDefaultPrintService(). This is the result:
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.ISO_A4);
    aset.add(new Copies(2));
    PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor,aset);
    if (service.length > 0) {
    System.out.println("Selected printer " + service[0].getName());
    DocFlavor[] flavors = service[0].getSupportedDocFlavors();
    for (int i = 0;i<flavors.length;i++) {
    System.out.println("Flavor "+i+": "+flavors.toString());
    Selected printer \\MUNIN-SERVER\HP LaserJet 2100 Series PCL 6
    Flavor 0: image/gif; class="[B"
    Flavor 1: image/gif; class="java.io.InputStream"
    Flavor 2: image/gif; class="java.net.URL"
    Flavor 3: image/jpeg; class="[B"
    Flavor 4: image/jpeg; class="java.io.InputStream"
    Flavor 5: image/jpeg; class="java.net.URL"
    Flavor 6: image/png; class="[B"
    Flavor 7: image/png; class="java.io.InputStream"
    Flavor 8: image/png; class="java.net.URL"
    Flavor 9: application/x-java-jvm-local-objectref; class="java.awt.print.Pageable"
    Flavor 10: application/x-java-jvm-local-objectref; class="java.awt.print.Printable"
    As you can see there is no support for text/html here.
    If anyone has a clue to what I'm missing here or any other (elegant, simple) way to print the contents of a JEditorPane, please speak up!
    Reply to: [email protected] or [email protected] or here in this forum

    Since you have 'printable' as one of your flavors, try this using a JTextPane (assuming you can dump your HTML into a JTextPane, which shouldn't be a big problem)...
    1. Have your JTextPane implement Printable
    ie. something like this:
    public class FormattedDocument extends JTextPane implements Printable 2. Read your HTML into the associated doc in the text pane.
    3. Implement the printable interface, since you have it as one of your available flavors (I'd imagine everybody has printable in their available flavors). Something like this:
    public int print(Graphics g, PageFormat pf, int pageIndex) {
            Graphics2D g2 = (Graphics2D) g;
            g2.translate((int)pf.getImageableX(), (int)pf.getImageableY());
            g2.setClip(0, 0, (int)pf.getImageableWidth(), (int)pf.getImageableHeight()); 
            if (pageIndex == 0)
                setupPrintView(pf);
            if (!pv.paintPage(g2, pageIndex))
                return NO_SUCH_PAGE;
            return PAGE_EXISTS;
        }Here's my setupPrintView function, which is executed once on page 0 (which still needs some polishing in case I want to start from page 5). It sets up a 'print view' class based on the root view of the document. PrintView class follows...
    public void setupPrintView(PageFormat pf) {
    View root = this.getUI().getRootView(this);
            pv = new PrintView(this.getStyledDocument().getDefaultRootElement(), root,
                               (int)pf.getImageableWidth(), (int)pf.getImageableHeight());Note of obvious: 'pv' is of type PrintView.
    Here's my PrintView class that paints your text pane line by line, a page at a time, until there is no more.
    class PrintView extends BoxView
        public PrintView(Element elem, View root, int w, int h) {
            super(elem, Y_AXIS);
            setParent(root);
            setSize(w, h);
            layout(w, h);
        public boolean paintPage(Graphics2D g2, int pageIndex) {
            int viewIndex = getTopOfViewIndex(pageIndex);
            if (viewIndex == -1) return false;
            int maxY = getHeight();
            Rectangle rc = new Rectangle();
            int fillCounter = 0;
            int Ytotal = 0;
            for (int k = viewIndex; k < getViewCount(); k++) {
                rc.x = 0;
                rc.y = Ytotal;
                rc.width = getSpan(X_AXIS, k);
                rc.height = getSpan(Y_AXIS, k);
                if (Ytotal + getSpan(Y_AXIS, k) > maxY) break;
                paintChild(g2, rc, k);
                Ytotal += getSpan(Y_AXIS, k);
            return true;
    // find top of page for a given page number
        private int getTopOfViewIndex(int pageNumber) {
            int pageHeight = getHeight() * pageNumber;
            for (int k = 0; k < getViewCount(); k++)
                if (getOffset(Y_AXIS, k) >= pageHeight) return k;
            return -1;
    }That's my 2 cents. Any questions?

  • Java Print Service - PDF

    I want to use the Java Print Service(JPS) API to programatically send
    PDF files to a printer. I need to send these files to the printer
    without any user intervention.
    At present i am trying to print on HP Laserjet 5100 series.
    I am able to print text files,Images (Jpeg) but have not been successfull in printing
    PDF files.
    DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
    DocFlavor flavor =new DocFlavor("application/pdf", "java.io.InputStream");
    The error I recieve is "Invalid Flavor". I have tried sending the PDF to the
    printer using a Document Flavor of INPUT_STREAM.AUTOSENSE.
    I also tried with
    DocFlavor flavor =new DocFlavor("application/octet-stream", "java.io.InputStream");
    When I do
    this the PDF file gets sent to the printer but what actually gets
    printed is garbage (control characters, overtyping, etc...).
    It appears the printer does not directly support PDF printing. The
    interesting thing is that I if I bring up a PDF file using Adobe Reader
    and press the Print button the file does get printed successfully!
    Can someone help me explain why Adobe Reader can print the file
    successfully but I am unable to do it programattically? Can someone
    suggest a different approach to take?.
    Regards,
    Raghu

    I suspect that it is because Adobe Reader isn't trying to print using the printer's non-existent PDF support. It is probably just sending generic image data to the printer as you would if you were printing Java 2D graphics using JPS.
    - Tomas

  • Print Service API Errors

    Hi,
    I am trying to use the new print services API's, I have a code example that will complie but failes at runtime.
    I am using Wepshere develoment studio client for the Iseries (V4.00).
    Can any one help me get this example running ?
    Error Message >>
    java.lang.NoClassDefFoundError: javax/print/PrintException
    Exception in thread "main"
    java.lang.NoClassDefFoundError: javax/print/DocFlavor
    Exception in thread "main"
    Example Code >>
    import java.lang.*;
    import java.io.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import javax.print.event.*;
    public class Print01
    static FileInputStream psStream;
    public static void main(String[] args)
    try
    psStream = new FileInputStream("file.ps");
    catch (FileNotFoundException ffne)
    System.out.println(ffne.toString());
    if (psStream == null)
    return;
    DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
    Doc myDoc = new SimpleDoc(psStream, psInFormat, null);
    PrintRequestAttributeSet aset =
    new HashPrintRequestAttributeSet();
    aset.add(new Copies(5));
    // aset.add(MediaSize.A4);
    aset.add(Sides.DUPLEX);
    PrintService[] services =
    PrintServiceLookup.lookupPrintServices(psInFormat, aset);
    if (services.length > 0)
    DocPrintJob job = services[0].createPrintJob();
    try
    job.print(myDoc, aset);
    catch (PrintException pe)
    System.out.println(pe.toString());
    Thanks

    Looks like a runtime CLASSPATH problem...
    Try to include this code in your main, and check that the version is the same as the one expected:
       System.out.println("JAVA VERSION  IS: " + System.getProperty("java.version"));

  • Java print services  UnsatisfiedLinkError

    i'm try to run the program given with java print services guide
    i.e PrintPS.java...
    and got this error...any idea what went wrong...
    Exception in thread "main" java.lang.UnsatisfiedLinkError: getDefaultPrinterName
    at sun.print.Win32PrintServiceLookup.getDefaultPrinterName(Native Method
    at sun.print.Win32PrintServiceLookup.getDefaultPrintService(Win32PrintSe
    rviceLookup.java:198)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Win32PrintServiceL
    ookup.java:61)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Win32PrintServiceL
    ookup.java:157)
    at javax.print.PrintServiceLookup.getServices(PrintServiceLookup.java:35
    9)
    at javax.print.PrintServiceLookup.lookupPrintServices(PrintServiceLookup
    .java:105

    I also have this same problem. Please help me out when you got the solution. my email address: [email protected]
    Thanks.

  • Turn off banner/titlebar from inside customize...

    Is it possible to turn off the banner/titlebar programmatically from your Edit/Edit Defaults page rather than from the Edit Region Settings (for the entire page)
    The call to PortletRendererUtil.renderPortletHeader(pr, out, headerTitle); seems to determine that it needs to render the title bar or not dependent upon these region settings.
    My thought would be to control the same thing it checks before it calles the renderPortletHeader.
    Ideas? Thanks.

    Well Stix Hart, I was starting to think I was going to have to wait FOREVER for the answer :-)
    Hehe, that was awesome, works like a charm. I totally forgot about using the Place dialog, let alone looking there for the setting.
    Thank you!
    Paul

  • How can I turn off the information that prints when a photo is emailed to printer?

    I need to stop the printer from printing the first page when sending an email to the printer's email address.

    There currently isn't an option to turn off the printing of the email.
    I am an HP employee

  • Turn off color management in printer driver?

    Hello folks:
    When I select an icc color profile in Aperture 3 in the Print dialog box, a warning pops up that says "Turn off Color Management in the Printer Driver." I have an Epson R2880, but for the life of me I cannot find a way to turn it off in the driver. Any thoughts? The Epson Printer Utility is also of no help.
    Thank you!
    --David

    Understanding that I have not actually used ColorJunki:
    -- A printer is always going to have something manage color. Either an ICC profile at the application level, or the printer driver.
    -- The warning is poorly worded. It means "Turn off the PRINTER color management and let Colorsync manage colors." Thus on the greyed out screen you will see that Colorsync is selected.
    -- To use a printer profiler you normally print a target sheet. Your software should tell you what settings to use.
    -- Next you read the target sheet and the profiler makes you an ICC profile of your printer/paper combination. (The same process that Canon, Epson, Red River, Illford, et al. follow.)
    -- You can now use your new, ColorMunki created ICC profile to soft proof your image as you adjust it and, finally,
    -- You use that same profile to print. (Remember, the profile is specific to a printer/paper combination and you will still have to set Quality/Media correctly for the paper.)
    By selecting the correct ICC profile on the first print screen, you automatically kill printer color management and, with a bit of luck, a good profile, and clement atmospheric conditions, you will actually get a good print.
    Trust me on this, I have been getting great prints from Aperture for years. My only gripe is that AP3 no longer lets me at the color options which I used to tweak for my cheap and cheerful Costco paper.

  • Turn off duplex, two sided, printing

    When I print from my email to my HP 6500A Plus printer it always prints two sided. I don't see any options for this, does anyone know how to turn this off?

    I am not at my home printer right now, nor am I near an AirPrint printer, but I have an HP PhotoSmart 7520 (I think that's the model) and when the print dialog box appears, there is an option right in the box - at the bottom of the box I believe - to turn off 2 sided printing. Or maybe it appears when you tap Range or one of the other options. Just try drilling deeper.
    This screenshot obviously does not include that line of dialog, but it would appear in the print window that looks like the window above.

  • Turn off the subject & email print feature

    I'm using Windows Vista and a wireless HP Photosmart 6510 printer. When I use eprint to print a photo it prints the photo and then prints, using the letter size bond, the email and/or email subject line. The problem is that I'm not only wasting paper, it lands on and messes up the wet photo? How do I turn off this feature?
    This question was solved.
    View Solution.

    That's what I was talking about with the signature line in emails from phones. For example, when using an iPhone it says "Sent from my iPhone". There should be an option in your phone under the mail settings to change the signature. If you clear it out completely, that should take care of everything for you. 
    -------------How do I give Kudos? | How do I mark a post as Solved? --------------------------------------------------------

Maybe you are looking for