Solved

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

Posted on 2000-04-20
3
2,019 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
[X]
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
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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.
Introduction to Processes
Starting up a Project

729 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