Solved

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

Posted on 2000-04-20
3
2,004 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
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…

679 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