Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any Easy Way to Print & Concatenate Different Reports?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00549636
Message ID:
00550173
Vues:
54
This message has been marked as the solution to the initial question of the thread.
>>Hi All,
>>
>>Does anyone know of an easy way to print multiple reports, all with different layouts, information, etc to files then easily concatenate them together for one monster print job? We have an almost infinite number of combinations of data and reports. For convenience sake we naturally have broken these into their component parts, printing each as needed. This suits all needs except the printing speed issue. (I want my cake and to eat it too.. <g>)
>>
>>We are dealing with a speed issue that results from multiple color print outs, each being a separate print job. We have been informaed that if we could concatenate all these teports into one file that this would markedly speed up the printing time.
>>
>>I know how to do the COPY /B + stuff but was wondering if anyone has ever tackled this beast and had a better method developed? I'm kind of wondering if there is a WSH approach I don't know of or some other low-level solution.
>>
>>The printer is one of the Xerox DocuColor 12's.
>>
>>Any suggestions gratefully appreciated...
>>
>>Thanks!!
>
>I have one pure VFP application which does exactly that kind of massive print job.
>
>For every client the necessary set of VFP reports (up to 4 reports per client) is run one-by-one to a separate print files with the names generated with SYS(2015) and extension ".pr1", then they are concatenated with DOS COPY command like this:
>
>lcCommand = "RUN copy /B *.pr1 " + lcPATH + lcOutputFileName	
>&lcCommand
>
>
>The huge output file is then passed to the mainframe printer.

As an alternative, you could use my DirectPrintOutput class (downloadable from the Files section as DIRPRTCLASS.ZIP) as the basis of a concatenation routine - the StartDocPrinter() API used by the DocOpen() method, changing it so that it takes an optional pointer to a file name, which would be used to direct printed output routed to it via DocWrite() or SpoolFile() rather than sending it to a printer device. DocOpen() could be modified as follows:
*-- Start a new spool document for the open printer
PROCEDURE DocOpen
   LPARAMETER tcDocName, <b>tcOutputFileName</b>
   LOCAL lIntState
   WITH THIS
      lIntState = .lInternal
      .lInternal = .T.
      IF ! lIntState
         .AddError(NULL)
      ENDIF
      IF ! .PrinterIsOpen()
         .AddError('DocOpen - no printer open to create Doc')
         .lInternal = lIntState
         RETURN .F.
      ENDIF
      IF .DocIsOpen()
         .AddError('DocOpen -  Already open; forcing close')
         .DocClose()
      ENDIF
      IF TYPE('tcDocName') # 'C'
         tcDocName = SYS(2015)
      ENDIF
      LOCAL cDocInfo,nAllocPtr, <b>nAllocPtrFileName
      IF TYPE('tcOutputFileName') = 'C'
         nAllocPtrFileName = oHeap.AllocString(tcOutputFileName)
      ELSE
         nAllocPtrFileName = 0
      ENDIF</b>
      nAllocPtr = .oHeap.AllocString(tcDocName)
      cDocInfo = NumToDWORD(nAllocPtr) + <b> ;
                 NumToDWORD(nAllocPtrFileName) + ;
                 REPL(CHR(0),4)</b>
      .nJobID = StartDocPrinter(.nhPrinter, 1, cDocInfo)
      IF .nJobID # 0
         StartPagePrinter(.nhPrinter)
         .cDocName = tcDocName
      ELSE
         .AddError('StartDocPrinter API # ' + TRANSFORM(GetLastError()))
         .nJobID = NULL
      ENDIF
      .oHeap.DeAlloc(nAllocPtr)
      <b>IF nAllocPtrFileName # 0
         .oHeap.DeAlloc(nAllocPtrFileName)
      ENDIF</b>
      .lInternal = lIntState
      RETURN .DocIsOpen()
   ENDWITH
ENDPROC
You'd then use the class as follows to spool output from multiple files together into a single file:
SET CLASSLIB TO DirPrtClass.PRG ADDITIVE
oPtr = CREATEOBJ('DirectPrintOutput')
WITH oPtr
   .PrinterOpen('LPT1:')
   .DocOpen('MySpoolJob','C:\OutputDir\ConcatenatedFile')
   .DocWrite(FILETOSTR('MyPrintFile1.PRN'))
   .DocWrite(FILETOSTR('MyPrintFile2.PRN'))
   .DocWrite(FILETOSTR('MyPrintFile3.PRN'))
   .DocClose()
ENDWITH
oPtr = NULL
This would spool the three files together into a single output file, C:\OutputDir\ConcatenatedFile without stripping control sequences, interpretation by the GDI, or the need to shell out to DOS; in your case, where the concatenation is being directed to a printer ultimately, you could simply open the correct printer and skip the creation of the intermediate concatenation file if it's addressible from Windows.

You could also do the concatenation using low-level file I/O.

Ed
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform