Printing with java technology

i am using paper size 8.5 x 11 and i need a very small margin in left side of the paper....i am not able to reduce the left-margin of the print paper...
if i am using x and y coordinates less then (0,0) then its missing some of the text....
help plz.
thank you

See Paper.setImageableArea(...)
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/print/Paper.html#setImageableArea(double, double, double, double)

Similar Messages

  • Front end printing with control technology problem with Mac platforms

    Hello,
       We are looking into replacing Host Spool Access method "F: Printing on front end computer" with the newer "front end printing with control technology" but are running into an issue.  Our Mac platforms cannot print duplex nor print multiple pages per side using the new technology.  We have followed SAP's recommendation to use the POST2 device type but it still won't allow full printing functionality.  Has anyone run into this and if so how did you overcome it?
    Thanks and Regards,
    Rich

    Hi Rich,
    I've had success getting duplex printing through "front end printing with control technology" with the Mac SAPgui as follows:
    In the Mac SAPgui, go to the Preferences window and select Printing (i.e. Preferences -> Desktop -> Printing).
    In the "Media sides" pull-down menu, select one of the "two-sided" choices (such as "two-sided-long-edge").
    Click the "Save" button at the bottom of the window (near the right hand side.
    Print to a Front end printer.
    I haven't figured out how to get n-up printing.
    /David Rosenberg

  • Front-end printing with control technology

    Can anyone elaborate on the new "Front-end printing with control technology" that was released with FEP 15, OSS Note # 821519?  Is this something I should be pushing Basis to implement?
    Thanks,
    John

    Hi Rich,
    I've had success getting duplex printing through "front end printing with control technology" with the Mac SAPgui as follows:
    In the Mac SAPgui, go to the Preferences window and select Printing (i.e. Preferences -> Desktop -> Printing).
    In the "Media sides" pull-down menu, select one of the "two-sided" choices (such as "two-sided-long-edge").
    Click the "Save" button at the bottom of the window (near the right hand side.
    Print to a Front end printer.
    I haven't figured out how to get n-up printing.
    /David Rosenberg

  • Cannot print on a USB printer with Java PrintService in Windows 2000. Why?

    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.

    Thanks a lot for the quick hint, but it did not help.
    I used BasicPrint.java and PrintJobWatcher.java of the samples for testing.
    Printing a GIF file works both to a parallel printer and a USB printer.
    Then I changed only the DocFlavor from DocFlavor.INPUT_STREAM.GIF to DocFlavor.INPUT_STREAM.AUTOSENSE, and that one works with my parallel printer, but on the USB printer the Ready light flashes twice, that's all.
    The ASCII file must have a "0C"X at the end to force a page eject on the parallel printer
    Maybe it is a matter of the DocFlavor, but which one?
    DocFlavor("application/octet-stream", "java.io.InputStream") works like DocFlavor.INPUT_STREAM.AUTOSENSE.
    DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST and DocFlavor.INPUT_STREAM.TEXT_HTML_US_ASCII cause sun.print.PrintJobFlavorException, and with DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII just nothing happens on either printer, not even an error message.
    I am getting the impression that nobody of the developers ever cared for testing such a simple thing as a plain ASCII file under Windows.
    My printers I am using for the tests are
    1. an old parallel-attached HP Laserjet 4 Plus and
    2. a borrowed USB-attached Samsung CLP-510 color laser

  • Cannot print on a USB printer with Java PrintService in Windows 2000

    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 24, 2008 11:34 AM
    By mistake I entered the same message another time after modifying the Subject instead of replacing the message. Sorry for that. If I knew how to delete it, I would. So please just ignore this one

    Thanks a lot for the quick hint, but it did not help.
    I used BasicPrint.java and PrintJobWatcher.java of the samples for testing.
    Printing a GIF file works both to a parallel printer and a USB printer.
    Then I changed only the DocFlavor from DocFlavor.INPUT_STREAM.GIF to DocFlavor.INPUT_STREAM.AUTOSENSE, and that one works with my parallel printer, but on the USB printer the Ready light flashes twice, that's all.
    The ASCII file must have a "0C"X at the end to force a page eject on the parallel printer
    Maybe it is a matter of the DocFlavor, but which one?
    DocFlavor("application/octet-stream", "java.io.InputStream") works like DocFlavor.INPUT_STREAM.AUTOSENSE.
    DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST and DocFlavor.INPUT_STREAM.TEXT_HTML_US_ASCII cause sun.print.PrintJobFlavorException, and with DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII just nothing happens on either printer, not even an error message.
    I am getting the impression that nobody of the developers ever cared for testing such a simple thing as a plain ASCII file under Windows.
    My printers I am using for the tests are
    1. an old parallel-attached HP Laserjet 4 Plus and
    2. a borrowed USB-attached Samsung CLP-510 color laser

  • Printing with Java

    Well, this is the third time I post this message, but I don't seem to find anyone interested in it, so I decided to put on some dukes... :-)
    I have never printed directly with Java, I have rather created pdf files or web-pages. However, Now I might be needing to print directly with Java (I will be using a ticket-printer), so I have done some investigation but I don't seem to find anything that I really like.
    I will be printing tickets, so I might use a simple image and text, only text, no special formatting or something. Any experiences, recommendations?
    Regards.

    This code could be useful for you. I don't know if it is platform independent:
    PrintingUtilities class
    import java.awt.*;
    import javax.swing.*;
    import java.awt.print.*;
    /** A simple utility class that lets you very simply print
    *  an arbitrary component. Just pass the component to the
    *  PrintUtilities.printComponent. The component you want to
    *  print doesn't need a print method and doesn't have to
    *  implement any interface or do anything special at all.
    *  <P>
    *  If you are going to be printing many times, it is marginally more
    *  efficient to first do the following:
    *  <PRE>
    *    PrintUtilities printHelper = new PrintUtilities(theComponent);
    *  </PRE>
    *  then later do printHelper.print(). But this is a very tiny
    *  difference, so in most cases just do the simpler
    *  PrintUtilities.printComponent(componentToBePrinted).
    *  7/99 Marty Hall, http://www.apl.jhu.edu/~hall/java/
    *  May be freely used or adapted.
    public class PrintUtilities implements Printable {
      private Component componentToBePrinted;
    /*  public static void printComponent(Component c, int device) {
        new PrintUtilities(c).print();
      public PrintUtilities(Component componentToBePrinted) {
        this.componentToBePrinted = componentToBePrinted;
      public void print(int device) {
        PrinterJob printJob = PrinterJob.getPrinterJob();
        printJob.setPrintable(this);
        //if(printJob.printDialog())
         try {
            printJob.setPrintService(printJob.lookupPrintServices()[device]);
            printJob.setCopies(1);
            printJob.print();
            //System.out.println(printJob.getPrintService());
          } catch(PrinterException pe) {
            System.out.println("Error printing: " + pe);
      public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
        if (pageIndex > 0) {
          return(NO_SUCH_PAGE);
        } else {
          Graphics2D g2d = (Graphics2D)g;
          g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
          disableDoubleBuffering(componentToBePrinted);
          componentToBePrinted.paint(g2d);
          enableDoubleBuffering(componentToBePrinted);
          return(PAGE_EXISTS);
      /** The speed and quality of printing suffers dramatically if
       *  any of the containers have double buffering turned on.
       *  So this turns if off globally.
      public static void disableDoubleBuffering(Component c) {
        RepaintManager currentManager = RepaintManager.currentManager(c);
        currentManager.setDoubleBufferingEnabled(false);
      /** Re-enables double buffering globally. */
      public static void enableDoubleBuffering(Component c) {
        RepaintManager currentManager = RepaintManager.currentManager(c);
        currentManager.setDoubleBufferingEnabled(true);
    An Example of use:
    import java.awt.*;
    import java.awt.print.*;
    import java.io.*;
    import javax.swing.*;
    public class PrintExample {
      public static void main(String[] args) {
        JFrame F = new JFrame() {
             public void paint(Graphics g) {
                  g.drawString("Printing a simple line!",20,20);
                  g.drawString("I hope this was useful",20,40);
        PrintUtilities printing = new PrintUtilities(F);
        Object[] array = PrinterJob.getPrinterJob().lookupPrintServices();
        for (int i=0; i<array.length;i++) System.out.println(i+" : "+array);
    System.out.print("Choose Printer device#: ");
    int device = askInteger();
    printing.print(device);
    private static int askInteger() {
         InputStreamReader ip = new InputStreamReader(System.in);
         BufferedReader br = new BufferedReader(ip);
         try {
         while(!false) {
         String read = br.readLine();
         try {
         return Integer.parseInt(read);
              } catch (NumberFormatException ex) {
              System.out.print("Write an integer please > ");
         } catch (IOException exception) {
         return -1;
    Some problems appears when I'm printing pictures.
    Please post a message if you figure out what to do.

  • Reports/print with java

    How to create reports with Java?
    where can I find javabeans to create reports with JBuilder?
    Thanks.

    JFreeReport is an open source report generator:
    http://www.object-refinery.com/jfreereport/index.html
    It's not a Javabean though.
    Another open source option is JasperReport (there's a link on the JFreeReport page), also (I think) not a Javabean.
    Hope this helps,
    Dave Gilbert
    www.object-refinery.com

  • Send a txt file to the printer with java

    Hello,
    I want to sent a txt file to the printer in java. I' am using the USB port. I can try to setup a dos command (print c:\test.txt), but I don't know the exactly command.
    There is also another solution in java I thing but I don't know the code!
    Can somebody give me the exact command for DOS and/or the code I have to write in java?
    THANX!!!!

    in dos imo you are not able to use usb-port. if your printer would be on lpt you could use javacomm ( http://java.sun.com/products/javacomm/index.html ). there is also another thread talking about this (print text to lpt). for your usb-problem i don't have a solution. but you could use JNI (java native interface). write code in c, compile to dll and use it in java.
    tobias
    ps: the other thread ( http://forum.java.sun.com/thread.jsp?forum=31&thread=224460 )

  • Printing with java J9

    Hi
    I just installed java J9 on my brand new hp iPAQ 4240 (windows mobile 5.0). The install file I used was: ibm-weme-wm50-arm-ppro11_6.1.0.20060727-102926.exe. And it works fine. Im going to develop an application that requires printing. Is there a java class for printing or?

    I think you can print from an applet, so long as it's a signed applet, but the problem is I think it will only print the applet or whatever you write to it. It's not likely to print the browser's contents. Anyway, I think that the browser has some settings regarding how things are printed, for example to not print a black page with white text, but print it in reverse, since it'll drain the printer's ink.

  • Print with Java

    Hi,
    I have some documents to be printing by user.
    I would like to print only with on click. I explain.
    I have put a button in my web application that is 'Print'.
    That i would like to do is, when the button is clicking by user, print start automaticaly whitout any other screen.
    Is that possible ?
    By default, when i want to print some documents, i always have a popup window that ask me which printer i want to choose. I want to specify it in code.
    Thanks for reply
    Imhotep

    All right, i have got any solution to do what i want.
    But is that possible to print the first page of a document in portrait, the second page in landscape and the last one in portrait ??

  • Using printer with java

    Hi all,
    I want to take print out of a text file from java. Do we hava any class or any way through which we can do this.
    Thanks in advance
    Regards,
    Arunkumar

    Look at the javax.print package.
    Here's a tutorial link you'll want, too:
    http://www-106.ibm.com/developerworks/java/library/j-mer0322/
    MOD

  • Printing with java app

    Hi all, I'm making a program for printing on continuous paper.
    I have 2 steps to my program so far and issues in all of them:
    1) Creating the print job, setting the paper size, margins, sending to printer
    2) I'm printing to a file, so I can remove the last 4 byets of the file that make the printer scroll the page out.
    The issues in the first part is that I can't seem to start printing at the top of the page (it always scrolls down like 2 inches). Changing the imageable area and margins don't seem to help with that or I just don't understand them. If I set margins to 0, it's just clipping the text and not printing it out properly. I also can't print more than 1 page size (height-wise), which sucks, considering I'm printing on continious paper.
        @Override
        public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
            if (page > 0) {
                return NO_SUCH_PAGE;
            Paper paper = new Paper();
            paper.setSize(612, 10000);
            double margin = 72;
            paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2, paper.getHeight()
            - margin * 2);
            pf.setPaper(paper);
            Graphics2D g2d = (Graphics2D)g;
            g2d.translate(pf.getImageableX(), pf.getImageableY());
            Font big = new Font("Times New Roman", Font.PLAIN, 12);
            Font small = new Font("Times New Roman", Font.PLAIN, 8);
            int Xlocation = 20;
            int y = 20;
            int count = 20;
            int i = 1;
            while (i < count){
                g2d.setFont(small);
                g.drawString("1", Xlocation , y);
                y += 8;
                g.drawString("2", Xlocation , y);
                y+=12;
                g2d.setFont(big);
                g.drawString("3", Xlocation , y);
                y += 8;
                g2d.setFont(small);
                g.drawString("4", Xlocation , y);
                y += 20;
                i++;
            // tell the caller that this page is part of the printed document
            return PAGE_EXISTS;
        }In the second part I'm removing the last 4 bytes of the file and adding a new line so it wouldn't scroll the page out after it is done printing. This works fine.
    I would like it to not prompt the user for file name, but give it a default name of something like "print.prn" and then run command prompt and enter command "copy /b print1.prn lpt1" which would send it to printer and then close command prompt. Is this possible?
    the second part:
            try {
                File target = new File(filename);
                RandomAccessFile file = new RandomAccessFile(target,"rw");
                file.setLength(target.length()-4); // Strip off the last 4bytes
                file.seek(target.length()); // set pointer to the end of file
                file.writeUTF("\n"); // add new line at the end of file
                file.close();
                Runtime rt = Runtime.getRuntime();
                rt.exec("cmd.exe /c start copy /b " +filename+ " lpt1");
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex);
            }  

    Anyone have any additional updates on this problem? We've just upgraded to JRE 1.6 update 10 and started seeing this on Windows XP machine. The printer that the users are trying to print to is a Lexmark T644 with a PS driver. I checked the Lexmark site and compared the driver on the users' machines with what is available on the Lexmark site. It appears that the users' machines has the latest version of the driver. I saw there was a bug open with Sun on the same type of problem on a non windows platform and related to having either an * or - in the printer name. I've verified that neither character is in the printer name in this instance. It also sounded as if on this bug that the problem could be reproduced every time. We're not seeing that either. Sometimes the printer accepts the work and other times is doesn't. Any insight on this.

  • "Using AES with Java Technology" first example: NoSuchAlgorithmException

    I am trying first example given in this page:
    http://developer.java.sun.com/developer/technicalArticles/Security/AES/AES_v1.html
    But I am getting following exception:
    java.security.NoSuchAlgorithmException: Algorithm AES not available
    at javax.crypto.SunJCE_b.a(DashoA6275)
    at javax.crypto.KeyGenerator.getInstance(DashoA6275)
    at AES.main(AES.java:41)
    Exception in thread "main"
    Please help me!!!
    Thanks a lot
    Fabrizio

    You must use Java 2 Platform, Standard Edition v 1.4.2 for AES to be present.... Or download a third party provider like Bouncy Castle

  • How does the SDK and Reader handle printing with orientation?

    I have a document that I want to print, and it contains a portrait page on Page 1, and a landscape page on Page 2.  Acrobat Reader correctly prints these pages (with a single print job), and I'm assuming it's because of the auto-rotate option on the print dialog.  Is this a feature of Reader, the API, or how the printer handles the request.  I've tried printing this PDF just using the JAva API, but the orientation remain portrait for all pages.  How does the Adobe Acrobat API deal with mixed orientation pages?  Ignore the fact that I did my test printing with Java, because my question is whether or not the auto orientation is a feature of the UI, the SDK, or the printer (or a combination).

    Same as the current Ipod Video or "Classic" there is an option under settings to toggle between original aspect ratio or Full Screen.
    Kenal0

  • C++ Debug Assertion Failed! - when printing with LOCL method G and GUI 620

    Hi all
    I've just raised an OSS message with SAP but don't think they'll help as the GUI version is no longer supported... if anyone else has come across this though and has any suggestions that would be great...
    Thanks
    Ross
    Hi
    We recently upgraded a few users to the 720 SAP GUI and had issues with LOCL printing, as we were still using the older "F: Printing on Front End computer" method of printing. As per SAP Note "Note 821519 - Front-end printing with control technology" the solution is to use method "G: Front end printing with Control Tech".
    However, we now get an issue with SOME users who are running the SAP GUI 620 patch 57. When they try and print to LOCL they get a pop up dialog box error:
    "Microsoft Visual C++ Debug Library
    Debug Assertion Failed!
    Program: C:\Program Files\SAP\FrontEnd\SAPgui\saplogon.exe
    File: fputs.c
    Line: 48
    Expressiom: steam != NULL"
    I appreciate that this old GUI is no longer supported BUT the SAP note states that 620 patch 56 is the minimum level for method "G" to work - and previous testing showed that it DID work ok. It seems only some of the 620 patch 57 users are affected - just wondering if you can advise why and if there is a 'quick fix' for this, perhaps an updated fputs.c file or something?
    The issue is that we literally have thousands of users on this version and cannot roll out 720 quickly enough & without some additional testing/costs etc. We have a 710 patch 18 version we can roll out but this can cause IE8 issues... neither do we wish to revert to control method "F" as this will then 'break' printing for those users.
    We have created a LOCL_OLD printer with method "F" but some users (for various reasons, including hard coded printers in bespoke transactions) cannot select this and have to use LOCL...
    If you are aware of the C++ debug assertion error and have any possible solutions that would be much appreciated.
    Many thanks
    Ross

    > I appreciate that this old GUI is no longer supported BUT the SAP note states that 620 patch 56 is the minimum level for method "G" to work - and previous testing showed that it DID work ok. It seems only some of the 620 patch 57 users are affected - just wondering if you can advise why and if there is a 'quick fix' for this, perhaps an updated fputs.c file or something?
    fputs.c is a source file that is used to compile the GUI. The assertion is thrown because an expected condition is not met. So even if you would take out the assertion, there's no guarantee it'll work because "something" on the operating system is not right.
    I suggest you compare installed software and windows hotfixes on the affected PCs vs. those who don't show this error. The error may also be that after the installation of the SAPGUI another software product was installed that replaced certain DLLs that are also used by the SAPGUI.
    Markus

Maybe you are looking for

  • Download error on Creative Cloud App.

    I keep getting the following error. I have gone through the steps of uninstalling and reinstalling the creative cloud app, but does not help. Don't know what to try next.

  • Why do I get "invalid drive E:/" when trying to update my itunes software

    Why do I get the message "invalid drive E:/" while trying to upgrade itunes? It causes the update to fail.

  • Error in Adaptor

    Hi Guys          I am configuring simple File -to-File adaptor with FCC. In communication channel for sender it showing error "Conversion initialization failed: java.lang.Exception: java.lang.Exception: java.lang.Exception: Error(s) in XML conversion

  • Contacts Do Not Appear To Be Synching From Outlook

    I turned on the sync contacts option under the Exchange/Outlook Mail settings on my iPhone iOS 8. So far, none of my unique work contacts have shown up on my iPhone with my personal contacts via iCloud. I'm not sure what else to do. I looked for an o

  • Report 9i performance on Web Application

    I've developed a report using Report Builder 9i. The report run smoothly in the builder, but it takes a very very long time to execute when called from web application. I've tried to execute the report's SQL statement in SQLPlus to see whether there