Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2000-04-20
3
1,996 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

792 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