Printing infinite no. of Copies (javax.print)

All,
When I execute the following code, the program never seems to return and a infinite no of copies are queued for printing. All I want to do is print one copy. Can somebody please explain what's wrong here?
     DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
     PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
     aset.add(MediaSizeName.ISO_A4);
     aset.add(new Copies(1));
     PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
     DocPrintJob pj = pservice.createPrintJob();
     InputStream psStream = null;
     try {
          psStream = new FileInputStream("example.ps");
     } catch (FileNotFoundException ffne) {
     Doc myDoc = new SimpleDoc(psStream, flavor, null);
     try {
               pj.print(myDoc, aset);
          } catch (PrintException e) {
JDK-Build 1.4.0-b92, WinNT
Printer: HP LaserJet 4050/4050N
Thanks
Prasad

I don't know what your problem is, but you should add e.printStackTrace() in your catches, in case there's an exception being thrown that you're smothering.
m

Similar Messages

  • Printed double number of copies (Invoice printing)

    Hi,
    While giving print for invoice from vf03 its printing double number of copies i.e. if i configure 3 copies in
    communication methods then it is printing 6 or 5 or 7 copies.
    Please need information where could be the problem.
    Thanks & Regards,
    Amit

    Hi Amit,
      The extra copies your getting are they blank?
    If you have used page-break option make sure there are no blank lines before it.
    Coz it will result in a blank page.
    Hope it helps!
    Much Regards,
    Amuktha.

  • Find the network printer print jobs names using  the javax.print

    hi friend ,
    i have a problem to find the network printer printjobs names using javax.prrint pacakge. And give the best sites for example of javax.print.

    Iterate the array from:
    PrintService[] services = PrintServiceLookup.lookupPrintServices( null, null );

  • Printing HTML to PS with javax.print

    Hi
    I'm trying to convert an .html file to .ps with javax.print.*,
    but I think that I need an html printer driver that support my Flavor HTML_UTF_*
    did anyone made this conversion ?
    do you any idea about this driver, and when can I download it?
    thanks ;)

    Doc doc = new SimpleDoc(book, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);I am really new to this and have not tried printing using the print service API, but from the little JavaDoc I can understand on these classes, it seems that you are saying you'll be providing a print object that implements Printable, but then you are actually passing in a Book object, which does NOT implement Printable (It implements Pageable.).
    So maybe try changing the DocFlavor to DocFlavor.SERVICE_FORMATTED.PAGEABLE ?

  • How can I print a html Using javax.print

    Hi friends,
    I am in big trouble . I use following code to print a html file using javax.print api.
    import java.io.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import javax.print.event.*;
    public class PrintPS
         public static void main(String args[]) {
              PrintPS html = new PrintPS();
         public PrintPS() {
         DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_HTML_HOST;
         PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
         aset.add(MediaSizeName.ISO_A4);
         aset.add(new Copies(1));
         aset.add(MediaTray.MAIN);
         PrintService pservices = PrintServiceLookup.lookupDefaultPrintService();
         if(pservices==null)
              System.out.println(" printer not found");
         if (pservices!= null) {
         System.out.println("selected printer " + pservices.getName());
         DocPrintJob pj = pservices.createPrintJob();
         try {
         InputStream fis = new FileInputStream("abc.html");
         Doc doc = new SimpleDoc(fis, flavor, null);
    System.out.println("printing started ");
         pj.print(doc, aset);
    System.out.println("printing completed");
         } catch (IOException ie) {
         System.err.println(ie);
         } catch (PrintException e) {
         System.err.println(e);
    This code gives me "sun.print.PrintJobFlavorException: invalid flavor"
    So i use all four TEXT_HTML flavor but i do not find the solution.
    I am able to print pdf, jpg, gif files but i can not able to print txt and html file.
    My printer supports txt and html printing becaue i do printing directolly by browser's or notpad's print command .

    Hi friends,
    I am in big trouble . I use following code to print a
    html file using javax.print api.Use Code Tags
    http://forum.java.sun.com/help.jspa?sec=formatting
    My printer supports txt and html printing becaue i do
    printing directolly by browser's or notpad's print
    command .Notepad & your browser prob. convert to the HTML/text(1) into the printers native format.
    1) I am suprised that it does not print text.

  • Printing a document to a specific printer - Linux RedHat

    Is it possible to print a document to a particular printer with the jdk1.4 in Linux RedHat? I am trying to select a printer with the following program (where args[0] is the name of the printer) but even though it seems that the program selects the right printer service the output allways goes to the default printer of the server.
    public class PrintFile {
    public static void main(String args[]) {
              String printername = args[0];
              String filename = args[1];
              if (printername != null) {
              if (filename != null) {
              try {
              javax.print.PrintService myprintservice = null;
              //Document flavor
              javax.print.DocFlavor flavor = javax.print.DocFlavor.INPUT_STREAM.POSTSCRIPT;
              //Print service for
              javax.print.attribute.PrintRequestAttributeSet aset = new javax.print.attribute.HashPrintRequestAttributeSet();
              aset.add(javax.print.attribute.standard.MediaSizeName.NA_LETTER);
              //Creating the Print Service
              javax.print.PrintService[] service = javax.print.PrintServiceLookup.lookupPrintServices(flavor,aset);
              if (service.length > 0) {
    for(int i=0;i<service.length;i++) {
    if (service.getName().equals(printername)) {
    myprintservice = service[i];
    break;
              if (myprintservice != null) {
              java.io.FileInputStream file = new java.io.FileInputStream(filename);
              javax.print.Doc doc = new javax.print.SimpleDoc(file ,flavor ,null);
              //Send the document to the printer
              javax.print.DocPrintJob pj = myprintservice.createPrintJob();
    System.out.println("Printing to: " + pj.getPrintService().getName());
              pj.print(doc, null);
              file.close();
    System.exit(0);
    } catch(Exception e) {System.out.println(e.toString());}
    Is this a bug or am I missing something?

    Yes, I've got the same problem, too. First I get all the print services using PrintServiceLookup.lookupPrintServices(DocFlavor flavor, AttributeSet attributes)
    Once I have the array of PrintService object I get the one that I'm looking for:
    for (int i=0; i<services.length; i++) {
    PrintService ps = services;
    if (ps.getName().equalsIgnoreCase(myPrinterName)) {
    myService = ps[i];
    break;
    But when I try to print through the object "myService" the printing always goes to the same printer!!!

  • PDF printing using javax.print

    Hi!
    I need to create an aplication that generates a PDF document and then prints it. For creating the PDF doc, I use the iText package.
    I have some problems with printing. I don't know how to print the document I generate. Could you give me a hint please? (I can print GIF docs, yet I do not know how to convert the PDF to GIF).
    Thanks in advance,
    Alex

    import javax.print.*;
    import javax.print.attribute.DocAttributeSet;
    import javax.print.attribute.HashDocAttributeSet;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    import javax.print.attribute.standard.Copies;
    import javax.print.attribute.standard.MediaSizeName;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    public class PDFfilePrinter {
    public static void main(String[] args) {
    DocAttributeSet fset = new HashDocAttributeSet();
    PrintRequestAttributeSet pset = new HashPrintRequestAttributeSet();
    String filename = "somefile.pdf"; //name of file to print
    DocFlavor docf = DocFlavor.INPUT_TYPE.PDF;
    PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
    if (0 < services.length) {
    DocPrintJob printer = services[0].createPrintJob(); //default printer on my system
    try {
    FileInputStream fis = new FileInputStream(filename);
    Doc toprint = new SimpleDoc(fis, docf, fset);
    pset.add(MediaSizeName.ISO_A4);
    pset.add(new Copies(1));
    printer.print(toprint, pset);
    } catch (PrintException e) {
    e.printStackTrace();
    } catch (FileNotFoundException fnfe) {
    fnfe.printStackTrace();
    Here's the code I'm working with for printing. This stuff works .... in a very strange way - it prints out all sort of crazy characters. I know I am doing something wrong and I think it's all in this line:
    DocFlavor docf = DocFlavor.INPUT_TYPE.PDF;
    Should I use a different flavor? I read somewhere that the PDF file format is not entirely supported bye javax.print. Could this be the problem?
    Thanks in advance,
    Alex

  • Get number of copies from print dialog

    Hi All,
    I am using javax.print API to display the print dialog, I am also able to successfuly print a document.
    My questions is how can get number of copies from the print dialog.
    I did log of googling, but no sucess...I have been trying from 1 day.
    Please help me.
    Thanks in advance.

    Here is the code:     // TODO Auto-generated constructor stub
              PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
              PrintService defaultPrinter = PrintServiceLookup.lookupDefaultPrintService();
              PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet();          
              selection = ServiceUI.printDialog(
                 null, 100, 100, services, defaultPrinter, null, attrs);           
              if(selection!=null){
                   selectedPrinter = selection.getName();               
              }Now once the printDialog is displayed i want to get the number of copies selected by the user. I tried all different options from Attribute, but not successful.
    Please help...
    Thanks.

  • Any one uses javax.print API and works?

    I have just downloaded 1.4 beta2 SDK and imported all the javax.print classes. I use the most simple test code as the following:
    FileInputStream fis = new FileInputStream("test.txt");
    try {
    DocFlavor psInFormat = DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII;
    Doc myDoc = new SimpleDoc(fis, psInFormat, null);
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new Copies(1));
    aset.add(MediaSizeName.ISO_A4);
    aset.add(Sides.ONE_SIDED);
    PrintService[] services = PrintServiceLookup.lookupPrintServices(psInFormat, aset);
    if (services.length > 0) {
    DocPrintJob job = services[0].createPrintJob();
    job.print(myDoc, aset);
    } catch (Exception e) {System.out.println(e.getMessage());}
    However, PrintServiceLookup.lookupPrintServices can't find my printer. I have 9 network printers connected to my system which range from HP LaserJet 4500 to 8100 and Acrobat PDFWriter. The API can't find any of my printer? What did I do wrong

    Hi Guys,
    First,
    If your trying to print any document sent by the server from the client machine u have to write a applet which recieves the output in form of stream and then print it. I could do these with JPEG, GIF and ASCII but could not do it with PDF (The sun doesn't have a implementation for PDF document printing, they just have a declaration may future released will help us print PDF).
    If u want the Print dialog box to appear use the following code that worked fine for me.
    public class SomeClass
    public static void main(String args[]) throws Exception
    PrintRequestAttributeSet pras =     new HashPrintRequestAttributeSet();
    DocFlavor flavor = DocFlavor.INPUTSTREAM.GIF;
    PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
    PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
    PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras);
    if (defaultService != null)
    DocPrintJob job = defaultService.createPrintJob();
    FileInputStream fis = new FileInputStream("somefile.GIF");
    DocAttributeSet das = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(byteArrayOutputStream, flavor, das);
    job.print(doc, pras);
    Thread.sleep(10000);
    If u do not want the dialog box to appear and just print to the default printer of the local machine use the following code
    public class SomeClass
    public static void main(String args[]) throws Exception
    PrintRequestAttributeSet pras =     new HashPrintRequestAttributeSet();
    DocFlavor flavor = DocFlavor.INPUTSTREAM.GIF;
    PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
    if (defaultService != null)
    DocPrintJob job = defaultService.createPrintJob();
    FileInputStream fis = new FileInputStream("somefile.GIF");
    DocAttributeSet das = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(byteArrayOutputStream, flavor, das);
    job.print(doc, pras);
    Thread.sleep(10000);
    Mean while if some body comes across any tweaks to print PDF documents using j2se1.4 please write to me at
    [email protected]
    Regards,
    Madhu

  • Javax.print binary format

    HI!
    I know there are several posts about javax.print and the binary format, but i found nothing that helps me.
    I'm trying to print a txt file
    public class print{
         public static void main(String args[]){
    //          Input the file
         InputStream textstream=null;
         try {
              textstream = new BufferedInputStream(new FileInputStream("test.txt"));
         catch (FileNotFoundException ffne) {
              ffne.printStackTrace();     
    //          Set the document type
         DocFlavor myFormat = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8;
    //          Create a Doc
         Doc myDoc = new SimpleDoc(textstream, myFormat, null);
    //          Build a set of attributes
         PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
         aset.add(new Copies(5));
         aset.add(MediaSizeName.ISO_A4);
         PrintService services =
              PrintServiceLookup.lookupPrintServices(myFormat, aset);
    //          Create a print job from one of the print services
         if (services.length > 0) {
              DocPrintJob job = services.createPrintJob();
              try {
                   job.print(myDoc, aset);
              catch (PrintException pe) {
                   pe.printStackTrace();
         else
         System.out.println("!hello");
    What's wrong witht this code?
    If I run it I get the output hello which meas that there is no printer to handle the file.
    Does anybody know a good tutorial about printing files?
    Pls help
    Thanks Jerome

    There's a long standing thread under Advanced Language Topics:
    javax.print and binary formats
    I'm surprised that a search of the forums didn't turn it up. - MOD

  • Javax.print problem: data not of declared type

    Hi all,
    I'm trying to print a simple text-only document with the below code but it keeps giving me an illegal argument exception. By the way, I've tried all the combinations of DocFlavor.*.* and SERVICE_FORMATTED.PRINTABLE and SERVICE_FORMATTED.PAGEABLE are the only ones working for me. Is this normal?
    Thanks!
    IllegalArgumentException:
    java.lang.IllegalArgumentException: data is not of declared type
            at javax.print.SimpleDoc.<init>(SimpleDoc.java:82)
            at DiagnosticsPane.actionPerformed(DiagnosticsPane.java:350)
    import java.io.*;
    import javax.print.*;
    import javax.print.attribute.*;
    class testPrint
         public static void main(String args[])
              PrintRequestAttributeSet pras =     new HashPrintRequestAttributeSet();
              DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
              PrintService ps[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
              PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
              PrintService service = ServiceUI.printDialog(null, 200, 200, ps, defaultService, flavor, pras);
              if (service != null) {
                   try {
                        DocPrintJob job = service.createPrintJob();
                        DocAttributeSet das = new HashDocAttributeSet();
                        FileInputStream fis = new FileInputStream("report.txt");
                        Doc doc = new SimpleDoc(fis, flavor, das);
                        try {
                             job.print(doc, pras);
                             System.err.println("Job sent to printer.");
                        } catch (PrintException e) {
                             System.err.println("Print error!\n\n" + e.getMessage());
                   } catch (FileNotFoundException e) {
                        System.err.println("File not found!\n\n" + e.getMessage());
    }

    Hi duffymo,
    I've tried all the available DocFlavors and even wrote a little program to list all my supported DocFlavors. And, I've only got 2 available for each of my printers, one being a Canon i320 and the other is a Adobe PDF printer.
    import javax.print.*;
    import javax.print.attribute.*;
    class listDocFlavor
      public static void main(String args[])
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        PrintService ps[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
        for (int j = 0; j < ps.length; j++) {
          DocFlavor df[] = ps[j].getSupportedDocFlavors();
          for (int i = 0; i < df.length; i++)
            System.err.println(j + ": " + df);
    0: application/x-java-jvm-local-objectref; class="java.awt.print.Pageable"
    0: application/x-java-jvm-local-objectref; class="java.awt.print.Printable"
    1: application/x-java-jvm-local-objectref; class="java.awt.print.Pageable"
    1: application/x-java-jvm-local-objectref; class="java.awt.print.Printable"

  • Mac Book Send  more then 300 Copies of Print command to Network Printer

    Dear Experts,
    I am Using Mac Book with OS X.
    I configured the Macbook to a Laserjet Printer 4250 via Printer server (DPU300). It has been working fine for few months.
    Now the problem is, when i send a print command from my mac book, it prints more then 300 copies. From other windows Box it works fine. I could not figure out the problem, please advice me.

    I should add that it's an HP photosmart 4280.I found it online and it shows the Mac 0SX operating system.

  • Javax.print problems on applet - bug on mac os implementation?

    Dear All,
    I am working on an applet and application that include a print function and I get a weird behaviour on MacOS in applet mode (both with Safari and Firefox - Mac OS X Versione 10.4.9 (Build 8P135) ). In contrast, things work fine on Windows XP (both Explorer 7 and Firefox with Java Plug-in 1.6.0_01) and even in MacOS when using the application.
    The problems are:
    - the print dialogue goes on and off a few times before letting the user interact with it
    - the page format in the dialogue is set to A5 (instead of the printer's default)
    - there is a small empty window appearing together with the dialogue and not disappearing even after the applet is closed
    Is this a known problem? If so, are there work-arounds?
    (I had no luck on Google about this)
    To reproduce the problem I created a stripped down version of the applet, in 2 files, I report it at the bottom of this message. I am using a modified version the PrintUtilities class from http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html
    Am I doing something wrong? Or shall I consider submitting a bug report?
    Any suggestion is welcome! Please let me know if I should provide more detailed information.
    Thank you in advance,
    Enrico
    PrintMe.java
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    public class PrintMe extends JApplet implements MouseListener{
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         public PrintMe() {
              super();
         private class MyComponent extends JPanel{
              private static final long serialVersionUID = 1L;
              public void paintComponent(Graphics g) {
                   super.paintComponent(g);
                  Graphics2D g2 = (Graphics2D) g;
                  g2.setColor(Color.black);
                  g2.drawString( "Test text", 0, g2.getFontMetrics().getHeight() );
         public void init() {
              MyComponent aComponent = new MyComponent();
              jContentPane = new JPanel();
              jContentPane.setLayout(new BorderLayout());
              jContentPane.add(aComponent);
              this.setContentPane(jContentPane);
              this.addMouseListener(this);
         public void print(){
              try{
                   PrintUtilities.printComponent(this);
              }catch (Exception e) {
                   e.printStackTrace();
         public void mouseClicked(MouseEvent e) {
              print();
         public void mouseEntered(MouseEvent e) {
              // not used
         public void mouseExited(MouseEvent e) {
              // not used
         public void mousePressed(MouseEvent e) {
              // not used
         public void mouseReleased(MouseEvent e) {
              // not used
    PrintUtilities.java
    import java.awt.Component;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.print.PageFormat;
    import java.awt.print.Printable;
    import java.awt.print.PrinterException;
    import java.awt.print.PrinterJob;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    import javax.swing.RepaintManager;
    import javax.swing.RootPaneContainer;
    /** 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.
    *  If you are going to be printing many times, it is marginally more
    *  efficient to first do the following:
    *    PrintUtilities printHelper = new PrintUtilities(theComponent);
    *  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) {
              new PrintUtilities(c).print();
         public PrintUtilities(Component componentToBePrinted) {
              this.componentToBePrinted = componentToBePrinted;
         public void print() {
              try{
                   PrinterJob printJob = PrinterJob.getPrinterJob();
                   printJob.setPrintable(this);
                   PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
                   if( printJob.printDialog(attributes) ){
                        try {
                             printJob.setJobName("MyName");
                             printJob.print(attributes);
                        } catch(PrinterException pe) {
                             System.err.println("Error printing: " + pe);
                             pe.printStackTrace();
              }catch (Exception e) {
                   e.printStackTrace();
         public int print(Graphics g, PageFormat pageFormat, int pageIndex) {
              if (pageIndex > 0) {
                   return(NO_SUCH_PAGE);
              } else {
                   RootPaneContainer rpc = (RootPaneContainer)(this.componentToBePrinted);
                   rpc.getRootPane().getGlassPane().setVisible( false );
                   Graphics2D g2d = (Graphics2D)g;
                   double sy = pageFormat.getImageableHeight() / componentToBePrinted.getHeight();
                   double sx = pageFormat.getImageableWidth() / componentToBePrinted.getWidth();
                   if( sx > sy ){
                        sx = sy;
                   }else{
                        sy = sx;
                   g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
                   g2d.scale(sx, sy);
                   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.
          *  @see enableDoubleBuffering
         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);
    }

    Trying to answer to myself..
    Is it possible that the problems are due to me mixing java.awt.print and javax.swing.print ?

  • Copies window printing in VF02/VF03 through output type

    Dear Experts,
    I have copied the standard smartform of the Invoice into YLB_BIL_INVOICE and i did the modification according to the client's requirement.
    In YLB_BIL_INVOICE, i have taken one window type as Copies Window and i have chosen the radio button Original and Copies. In the window I wrote the code for Copies like Original, Factory Copy, Buyer Copy, Triplicate and Marketing Copy based on SFSY-COPYCOUNT checking. I haven't changed the standard program(RLB_INVOICE).
    And I have assigned the smartform YLB_BIL_INVOICE and RLB_INVOICE in NACE settings. When I am viewing the print using VF02/VF03 with output type which configured by SD Consultant it is not showing the Copies means if I mention Number of Copies as 4 in print preview it is showing only single Page and when I gave the print with number of copies as 4 Pages are printing 4 copies but the name of the copies is same for all 4 pages like 1st page as Original and 2nd page as Original etc..
    I debugged the code and i am getting NAST-ANZAL = 1. in program, I think it should be 4. Please give me some input to resolve this issue?
    Thanks n Regards,
    Muralikrishna
    Edited by: muraliabap on Feb 14, 2011 6:35 AM

    Hi,
    I am not clear about the following context.
    muraliabap wrote:
    if I mention Number of Copies as 4 in print preview it is showing only single Page and when I gave the print with number of copies as 4 Pages are printing 4 copies
    Where did you give the no of copies as 4? In the message or Print Dialog?
    NAST-ANZAL is from message and OUTPUT_OPTIONS-TDCOPIES is from the Print Dialog. For copies window, no of copies is fetched through OUTPUT_OPTIONS-TDCOPIES (or the Print Dialog), thus SFSY-COPYCOUNT is changed accordingly .
    Check the this [link|http://wiki.sdn.sap.com/wiki/display/ABAP/Copies(duplicate,etc.)]

  • Different titles for different copies while printing an invoice

    hi guys !!
    I want to print different titles on copies as follows...
    1st copy - "Original"
    2nd copy - "Duplicate"
    3nd copy - "Triplicate"...
    i have used system vairable SFSY-COPYCOUNT....
    in my 'Copies Window'..i have the following program lines..
    CASE SFSY-COPYCOUNT.
    WHEN 1.
    TEXT = 'Original'.
    WHEN 2.
    TEXT = 'Duplicate'.
    WHEN 3.
    TEXT = 'Triplicate'.
    ENDCASE .
    but the problem is this variable is always 001.....
    i guess all the variables are initialised when ever the next copy is printed....
    any idea why????
    thnx ....

    Poonam,
    Instead of that you just add a window and in that widows text editor hardcode it as
    ORIGINAL []
    DUPLICATE[]
    TRIPLICATE[]
    Now in the driver program do it as below
    DATA: ls_ctrl_params   LIKE ssfctrlop,   "Control Parameters
            ls_outp_opts     TYPE ssfcompop.   "Output Options
    To print 3 copies
      MOVE '3' TO ls_outp_opts-tdcopies. 
    In the function  module
    CALL FUNCTION v_fnam
        EXPORTING
          control_parameters = ls_ctrl_params
          output_options     = ls_outp_opts
    K.Kiran.

Maybe you are looking for