Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing problem in Paradox 8 2

Status
Not open for further replies.

mtastad

Programmer
Feb 5, 2002
18
US
I want to be able to print out a report on a laser printer and then print out labels on a label printer when the user clicks on one button. I have tried all of the object pal code that I can think of to internally switch the printers (printerSetCurrent..) but it is not working. Is there a trick to setting the current printer? Also, can I prevent the windows print dialog from displaying and control the print process with object pal? I am using Windows2000. Thanks!
 
Paradox 8 has a lot of problems with printer control, especially with HP products. Try using older printer drivers. The answer to your second question is 'Yes' - the below includes errortrapping.

var
r report
RepInfo reportPrintInfo
endvar

if not r.load("reportname",WinStyleDefault+WinStylehidden)
then errorshow()
endif

if not r.print(repInfo)
then errorshow()
endif

if not r.close()
then errorshow()
endif
 
Thanks!! I used the ReportPrintInfo variable type and it worked great. One more question - Is there an easy way to store the current printer settings so that I can restore the printer settings when I am finished with the routine.
 
I would assume you could use constantNameToValue() to get the printer constants and write them to variables, but I've never tried it.

Mac
 
mtastad,

Here's an example that:

1. Prints a report to a specific printer
2. Hides the Print dialog from the user
3. Saves and then restores the default printer.

Code:
method pushButton(var eventInfo Event)
var
   piCurrent,
   piAcrobat    printerInfo
   rpt          Report
   rpi          ReportPrintInfo
   astrPrinters Array[] String
   strPrintInfo String
   siCounter    SmallInt
endVar

const
   DEVICE = "Acrobat PDFWriter"
endConst

   ; save current config
   printerGetInfo( piCurrent )  ; save current info

   ; locate the target printer
   enumPrinters( astrPrinters )
   for siCounter from 1 to astrPrinters.size()
      strPrintInfo = astrPrinters[ siCounter ]
      if strPrintInfo.search( DEVICE ) = 1 then
         quitloop
      else
         strPrintInfo = "" ; clear for error condition
      endIf
   endFor

   if strPrintInfo = "" then ; error
      msgStop( "Can't Print Report", "Reason: " +
               DEVICE + " doesn't appear to be installed." )
   else
      ; run the report.
      printerSetCurrent( strPrintInfo )

      ; print the report w/o the Print dialog.  (Yes, just two lines.)
      rpi.name = ":work:customer"
      rpt.print( rpi )

      ; restore current config
      printerSetCurrent( piCurrent.DeviceName + "," +
                         piCurrent.DriverName + "," +
                         piCurrent.PortName )

   endIf

endMethod

As you can probably tell, this prints the CUSTOMER report in the SAMPLES directory to the driver that creates Adobe PDF files. I wrote it using Paradox 8, but it should work in most versions of Paradox.

To adapt this for your own needs, you'll need to know the name of the printer to assign to the DEVICE constant. While you can "eyeball" this, it's probably best to use a script to determine the actual value that Paradox returns. Something like this should work:

Code:
var
  astrPrinters  Array[] String
endVar

   enumPrinters( astrPrinters )
   astrPrinters.view( "Current Printers" )

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top