Solved

PB 6.0: How to change the printer's setup ?

Posted on 2000-04-20
3
1,974 Views
Last Modified: 2010-08-05
I would like to change the printer's setup by the programming
in PowerBuilder 6.0 (HP LaserJet 1000)

I have found the "PrintSend" function in help:
"PrintSend" sends an arbitrary string of characters to the printer.
"PrintSend" is usually used for sending escape sequences that change the printer's setup.
But Escape Sequences are printer specific... (Oops !)

In reality, I would like to change the default orientation of paper to landscape.

Example:
--------

Long Job

Job = PrintOpen()      //Open a print job
PrintSend(Job,"???")      //Send an escape sequence
...
PrintClose(Job)            //Send the job to the printer or spooler

Thanks in advance, Cedric (:=D
0
Comment
Question by:onb294
3 Comments
 
LVL 1

Accepted Solution

by:
joseph_schuler earned 1000 total points
ID: 2743858
A friend of mine looked for a way to do this several weeks ago.  He could find no direct way of doing it.  He ended up using the pageset dll.  The downloaded it from MSDN as: PageSet.exe
   (http://support.microsoft.com/download/support/mslfiles/PageSet.exe)

This DLL uses the WIN32 API to do its work.

The following sample resets print orientation:
Integer      li_RC
Long            ll_PrintJobNum
String      ls_ErrorMsg, ls_DebugInfo, ls_OutPutName


OLEObject      ole_PageSet
Long                  ll_ReturnCD

// create and connect to OLE
ole_PageSet = CREATE OLEObject
ll_ReturnCD = ole_PageSet.ConnectToNewObject("PageSet.PrinterControl")
IF ll_ReturnCD <> 0 THEN
      MessageBox("","Unable to connect to OLE! Error Code: " + String(ll_ReturnCD))
      RETURN -1
ELSE
      MessageBox("","Connected to OLE!")
END IF

ole_PageSet.ChngOrientationLandscape()

// send multiple print datawindws as same job
ll_PrintJobNum = PrintOpen("zzz")
IF ll_PrintJobNum = -1 THEN
      ls_ErrorMsg = "Unable to access Print Job Number!"
      GOTO FATAL_ERROR
END IF

li_RC = PrintDataWindow(ll_PrintJobNum,dw_page1)
IF li_RC = -1 THEN
      ls_ErrorMsg = "Unable to print Page 1!"
      GOTO FATAL_ERROR
END IF

li_RC = PrintDataWindow(ll_PrintJobNum,dw_page2)
IF li_RC = -1 THEN
      ls_ErrorMsg = "Unable to print Page 2!"
      GOTO FATAL_ERROR
END IF

li_RC = PrintClose(ll_PrintJobNum)
IF li_RC = -1 THEN
      ls_ErrorMsg = "Unable to Close Print Job!"
      GOTO FATAL_ERROR
END IF

ole_PageSet.ReSetOrientation()

ll_ReturnCd = ole_PageSet.DisconnectObject()
IF ll_ReturnCD <> 0 THEN
      MessageBox("","Unable to Disconnect from OLE! Error Code: " + String(ll_ReturnCD))
ELSE
      MessageBox("","Disconnected from OLE!")
END IF

DESTROY ole_PageSet
MessageBox("","ole_CPPLicense Destroyed!")


RETURN 1

//-----------------------------------------------------------------------------
// something happened in this function
// log as_id in error with error message
FATAL_ERROR:
ole_PageSet.ReSetOrientation()
      ls_DebugInfo = This.Title + ": wf_print_bnw: "
      SetNull(ls_OutPutName)
      wf_log_asid_status(ic_AS_AsId, -1, ls_ErrorMsg, ls_DebugInfo, ls_OutPutName)
      RETURN -1

I hope this helps
0
 

Author Comment

by:onb294
ID: 2751380
Thank you very much for your help...

Cedric   (:=D
0
 
LVL 1

Expert Comment

by:Geramel
ID: 14151646
HOw to display the Printing preferences using vb?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now