Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

770 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