Highlighted
Absent Member.
Absent Member.
1752 views

[archive] Print to more than one printer - win$printer

[Migrated content. Thread originally posted on 15 May 2008]

Hi,

Subject may be a bit confusing, so hopefull this explains.

I have say invoice print program.
The user runs this in batch mode and it will print on a printer of their choice through WIN$PRINTER.
Could be 10 invoices, could be 100 - who knows and who cares anyway.

Part way though the invoice print its decided that the next invoice will be emailed and printed as normal.
So the program open output a flat file and writes very basic html wraps around the print lines.

THis is no good and I now need logos etc to be on the document.
I thought I could just assign this to -P SPOOLER too and let it write to the pdf printer.

But clearly I thought wrong.
Is this feasible at all, or can you suggest a better way?

Many thanks,

Shaun
0 Likes
6 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Print to more than one printer - win$printer

It is certainly possible as that is what our company does. Basically we open 2 printers and each printer has a job id. Then, we send each print line to both job ids.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Print to more than one printer - win$printer

OK,

I think I see what my problem may be.
I'm printing to a printer with one job and trying to print via cutepdf to the other job.

I've searched and found this - see post 14

http://www.acucorp.com/support/supported/customer_forum/showthread.php?t=827&highlight=JOB

I think I now need to use GET-JOB-STATUS and SET-JOB-STATUS.
I'll see how I go today.

SHaun
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Print to more than one printer - win$printer

I'm either tired today or possibly being a bit thick?
I've read documentation until I'm blue in the face.

Have a look at this and tell me what I'm doing wrong if you wouldn't mind.
I always thought it was pick the printer you want to print to, then open the file etc.

Basically what i'm trying si simulate is our invoicing routine.
In this case its suppose to be ask them where do they want to print the thing.
Then using cutepdf there is a printer called "Logic PDF" present and this is where the equivilent pdf will be created for emailing.

I'll try with just windows printers on Monday and bypass cutepdf incase its really causing the grief?

Thanks,

Shaun


      *THE PRINT PDF FILE
           CALL "WIN$PRINTER" USING WINPRINT-SETUP-OLD
                 GIVING WS-RESULT           
           OPEN OUTPUT PRINT-FILE
           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB 0
                 GIVING WS-PRINT-JOB-ID

      *THE EMAIL PDF FILE
           INITIALIZE WINPRINT-DATA
           MOVE "Logic PDF"        TO WINPRINT-NAME
           CALL "WIN$PRINTER" USING  WINPRINT-GET-PRINTER-INFO-EX
                                     WINPRINT-SELECTION
                 GIVING WS-RESULT
           IF WS-RESULT = 1
              CALL "WIN$PRINTER" USING  WINPRINT-SET-PRINTER-EX
                                        WINPRINT-SELECTION
                 GIVING WS-RESULT
           ELSE
              CALL "WIN$PRINTER" USING WINPRINT-SETUP-OLD
                 GIVING WS-RESULT
           END-IF
           OPEN OUTPUT EMAIL-FILE
           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB 0
                 GIVING WS-PRINT-JOB-ID


           MOVE "This is the invoice print" TO    PRINT-LINE

           MOVE "This is the email print"   TO    EMAIL-LINE

           WRITE PRINT-LINE  AFTER 1

           WRITE EMAIL-LINE  AFTER 1

           CLOSE PRINT-FILE
                 EMAIL-FILE
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Print to more than one printer - win$printer

You must set the job # before writing to the printer. The job # has to be set prior to any communication to the printer such as setting fonts, graphics, printing. Also the job number should be different for each job. For example:

CALL "WIN$PRINTER" USING WINPRINT-SET-JOB
  WS-PRINT-JOB-ID-1.
WRITE PRINT-LINE AFTER 1.


CALL "WIN$PRINTER" USING WINPRINT-SET-JOB
  WS-PRINT-JOB-ID-2.
WRITE EMAIL-LINE AFTER 1.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Print to more than one printer - win$printer

Hi,

OK, I'm very close now.
I currently have in the actual invoice program an invoice print and a pdf file created which is a copy of the invoice - with logos etc.

I have a problem with the font now.
All our prints use "Courier New" Size 9

Basically the second printer if you like won't set the font.
Seems to be using a default?
Would someone mind just looking at this and see if you see something stupid that I'm doing.
Failing that I'll head off to tech support.

Thanks in advance,
Shaun

      ******************************************************************
      *  I D E N T I F I C A T I O N   D I V I S I O N .               
      ******************************************************************
      *
       IDENTIFICATION DIVISION.
       PROGRAM-ID.    printtwice.
       AUTHOR.        Sysco Software Limited.
       INSTALLATION.  Sales Ledger.
      *FUNCTION.     
       DATE-WRITTEN.  03/09/91   12:00.
       DATE-COMPILED. 18-Jun-99 15:55.
       SECURITY.      Copyright (c) 2000 Sysco Software Limited.
      *
      ******************************************************************
      *  E N V I R O N M E N T   D I V I S I O N .                     
      ******************************************************************
      *
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SPECIAL-NAMES.
           CURRENCY IS "#".
      *
      *{Bench}activex-def
      *{Bench}end
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
      *
           SELECT  PRINT-FILE     ASSIGN TO "-P SPOOLER"
                   ORGANIZATION    LINE SEQUENTIAL
                   FILE STATUS     FILE-STAT.
      *
           SELECT  EMAIL-FILE    ASSIGN TO "-P SPOOLER"
                   ORGANIZATION    LINE SEQUENTIAL
                   FILE STATUS     FILE-STAT.
      *
      ******************************************************************
      *  D A T A   D I V I S I O N .                                   
      ******************************************************************
      *
      *{Bench}file-control
      *{Bench}end
       DATA DIVISION.
       FILE SECTION.
      *
       FD  PRINT-FILE.
       01  PRINT-LINE           PIC X(132).
      *
       FD  EMAIL-FILE.
       01  EMAIL-LINE           PIC X(132).
      *
      ******************************************************************
      *  W O R K I N G   S T O R A G E   S E C T I O N .               
      ******************************************************************
      *
      *{Bench}file
      *{Bench}end
       WORKING-STORAGE SECTION.
      *{Bench}acu-def
       COPY "acugui.def".
       COPY "acucobol.def".
       COPY "crtvars.def".
       COPY "showmsg.def".
      *{Bench}end
       COPY "fonts.def".
       COPY "winprint.def".
      *
       01 WS-COPYRIGHT        PIC X(39) VALUE
                              "Copyright (c) 2000 Sysco Software Ltd".
       01 WS-VERSION          PIC X(26) VALUE "CHARIOT Version 2.4.1".
      *
      ******************************************************************
      *  Data File Name Variables.                                     
      ******************************************************************
      *
      ******************************************************************
      *  Insert 77 & 88 Level Flags & Indicators Here.                 
      ******************************************************************
      *
       77  WFONT-STATUS         PIC 9(02) VALUE ZEROS.
       77  WS-PRINT-FONT-HANDLE USAGE IS HANDLE OF FONT VALUE NULL.
       77  WS-PDF-FONT-HANDLE   USAGE IS HANDLE OF FONT VALUE NULL.
       77  FILE-STAT            PIC X(02) VALUE ZEROS.
       77  WS-RESULT            PIC 9(02) VALUE ZEROS.
       77  WS-PRINT-JOB-ID      USAGE SIGNED-INT.
       77  WS-EMAIL-JOB-ID      USAGE SIGNED-INT.
      *
      ******************************************************************
      *  L I N K A G E   S E C T I O N .                               
      ******************************************************************
      *
      *{Bench}copy-working
      *{Bench}end
      *
      ******************************************************************
      *  P R O C E D U R E   D I V I S I O N .                         
      ******************************************************************
      *
      *{Bench}linkage
      *{Bench}end
       SCREEN SECTION.
      *{Bench}copy-screen
      *{Bench}end
       PROCEDURE DIVISION.
       MAIN-ROUTINE SECTION.
       MAIN-CONTROL.
      *
      *load desired font
      *One to print and one for PDF - just to split it up
           INITIALIZE  WFONT-DATA
           SET     WFDEVICE-WIN-PRINTER  TO TRUE
           SET     WFCHARSET-DEFAULT     TO TRUE
           MOVE    "Courier New"         TO WFONT-NAME
           MOVE    20                    TO WFONT-SIZE
           CALL    "W$FONT"  USING WFONT-GET-FONT,
                                   WS-PRINT-FONT-HANDLE,
                                   WFONT-DATA
           INITIALIZE  WFONT-DATA
           SET     WFDEVICE-WIN-PRINTER  TO TRUE
           SET     WFCHARSET-DEFAULT     TO TRUE
           MOVE    "Courier New"         TO WFONT-NAME
           MOVE    30                    TO WFONT-SIZE
           CALL    "W$FONT"  USING WFONT-GET-FONT,
                                   WS-PDF-FONT-HANDLE,
                                   WFONT-DATA
      *
      *THE PRINT PDF FILE
           PERFORM INIT-PRINTER-DATA
           MOVE "Microsoft Office Document Image Writer"   
                                   TO WINPRINT-NAME
           CALL "WIN$PRINTER" USING  WINPRINT-GET-PRINTER-INFO-EX
                                     WINPRINT-SELECTION
                 GIVING WS-RESULT
           IF WS-RESULT = 1
              CALL "WIN$PRINTER" USING  WINPRINT-SET-PRINTER-EX
                                        WINPRINT-SELECTION
                 GIVING WS-RESULT
           ELSE
              CALL "WIN$PRINTER" USING WINPRINT-SETUP-OLD
                 GIVING WS-RESULT
           END-IF 
           OPEN OUTPUT PRINT-FILE
           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB 0
                 GIVING WS-PRINT-JOB-ID
           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB WS-PRINT-JOB-ID
           INITIALIZE                 WINPRINT-DATA
           MOVE  WS-PRINT-FONT-HANDLE TO WPRTDATA-FONT
           CALL  "WIN$PRINTER"     USING WINPRINT-SET-FONT,
                                         WINPRINT-DATA
                 GIVING   WS-RESULT


      *THE EMAIL PDF FILE         
           PERFORM INIT-PRINTER-DATA
           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB -1
                 GIVING WS-EMAIL-JOB-ID
      *     MOVE "Logic PDF"        TO WINPRINT-NAME
           MOVE "Microsoft Office Document Image Writer"
                                   TO WINPRINT-NAME
           CALL "WIN$PRINTER" USING  WINPRINT-GET-PRINTER-INFO-EX
                                     WINPRINT-SELECTION
                 GIVING WS-RESULT
           IF WS-RESULT = 1
              CALL "WIN$PRINTER" USING  WINPRINT-SET-PRINTER-EX
                                        WINPRINT-SELECTION
                 GIVING WS-RESULT
           ELSE
              CALL "WIN$PRINTER" USING WINPRINT-SETUP-OLD
                 GIVING WS-RESULT
           END-IF
           OPEN OUTPUT EMAIL-FILE       
           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB WS-EMAIL-JOB-ID
           INITIALIZE                    WINPRINT-DATA
           MOVE  WS-PDF-FONT-HANDLE   TO WPRTDATA-FONT
           CALL  "WIN$PRINTER"     USING WINPRINT-SET-FONT,
                                         WINPRINT-DATA
                 GIVING   WS-RESULT

           MOVE "This is the invoice print" TO    PRINT-LINE
           MOVE "This is the email print"   TO    EMAIL-LINE

           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB WS-PRINT-JOB-ID
           WRITE PRINT-LINE  AFTER 1

           CALL "WIN$PRINTER" USING WINPRINT-SET-JOB WS-EMAIL-JOB-ID
           WRITE EMAIL-LINE  AFTER 1

           CLOSE PRINT-FILE
                     EMAIL-FILE
           .     
      *
       EXIT-PROG.
      *
           STOP RUN.

       INIT-PRINTER-DATA.
      *
           INITIALIZE WINPRINT-NAME
                      WINPRINT-PORT
                      WINPRINT-DRIVER
                      WINPRINT-DRV-VERSION
                      WINPRINT-NO-OF-PRINTERS
                      WINPRINT-IS-DEFAULT
                      WINPRINT-COPIES
                      WINPRINT-ORIENTATION
                      WINPRINT-QUALITY
                      WINPRINT-CURR-ORIENTATION
                      WINPRINT-CURR-COPIES
                      WINPRINT-DUPLEX
                      WINPRINT-COLLATE
                      WINPRINT-COLOR
                      WINPRINT-CURR-DUPLEX
                      WINPRINT-CURR-COLLATE
                      WINPRINT-CURR-PAPERSIZE
                      WINPRINT-CURR-TRAY
                      WINPRINT-CURR-COLOR
                      WINPRINT-JOB-TITLE
           .

      *{Bench}copy-procedure
       COPY "showmsg.cpy".
      *{Bench}end
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Print to more than one printer - win$printer

One issue I see right away is that you load the fonts prior to opening the printers. This has the consequence that both will be scaled to whatever is the current printer.
Try to change your sequence to:
OPEN PRINTER-FILE
*Load font for PRINTER-FILE
OPEN PDF-FILE
*Load font for PDF-FILE

This is significant because printers have different resolution.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.