Set the paper tray

General discussion forum about all things Team Developer 6.x
EwaldP
Austria
Posts: 57
Joined: 07 Mar 2017, 08:00
Location: Austria

Set the paper tray

Post by EwaldP » 27 Apr 2017, 14:24

Hi,

is there a way to set the paper tray of a printer programmatically? I have to print many documents (docx, pdf, txt, ...) in a loop with ShellExecuteW (https://msdn.microsoft.com/en-us/librar ... s.85).aspx). Each document can be printed to a different printer or different tray.

Otherwise I have to install for each tray a printer device.

Any hints?
Regards
Ewald
Ewald P. Palmetshofer
EDV-Hausleitner GmbH
4020 Linz
www.edv-hausleitner.at

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 123
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: Set the paper tray

Post by Jeff Luther » 27 Apr 2017, 17:56

Here is a possible solution for you, Ewald. I have a 4gig stash of tests et al for TD dating back to the early '90s and found this one in my PrinterPrint folder.

Note that I don't have a multi-tray printer, so I am unable to test whether the code can display and change trays for a single printer. I tested by changing from my HP laserjet to a PDFwriter printer and it works fine.

Maybe this might be what you want. To automate you could hard-code in the printer defaults for each printer and/or tray you need, then cycle through those as you need to print to a certain one.

Let us know if you get something to working with your test case, especially if it's multiple trays on the same printer you are printing to. The sample is titled PrintTo2Trays, but may be misnamed (?) since I can't test to > 1 tray.
You do not have the required permissions to view the files attached to this post.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

thomas.uttendorfer
Site Admin
Site Admin
Germany
Posts: 52
Joined: 05 Mar 2017, 17:19
Location: Munich Germany

Re: Set the paper tray

Post by thomas.uttendorfer » 28 Apr 2017, 08:15

Hi Jeff,
this is the solution we found also.

You have to configure one hardware printer twice (or more) in Windows.
In the Windows printer configuration you can set a default paper tray for each Windows printer and name the printer apropriately.
In TD you just switch the printer in order to print to a different tray.
This solution works.

Regards
Thomas
Thomas Uttendorfer
[ frevel & fey ] Software-System GmbH
https://thomasuttendorfer.wordpress.com/

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 123
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

Re: Set the paper tray

Post by Jeff Luther » 28 Apr 2017, 16:37

Thanks for letting us know, Thomas, as well as for the hint on setting up multiple trays for a single printer:
You have to configure one hardware printer twice (or more) in Windows.
Sounds like this should work for Ewald as well.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

Didiman
Germany
Posts: 8
Joined: 21 Mar 2017, 13:05
Location: Bremen, Germany

Re: Set the paper tray

Post by Didiman » 03 May 2017, 10:55

Hi,

maybe you can use a sideeffect of:

Code: Select all

On SAM_ReportStart
	If sAktBin != ''
		Call SalReportSetPrinterTray( SalNumberToWindowHandle(wParam), RPT_PageAll, sAktBin )
	Return TRUE
Because this also changes the Tray of the Windows default printer. So you can try to make a Dummy Print of a Report and then use the Settings of the default printer.

Greetz

--Andreas

EwaldP
Austria
Posts: 57
Joined: 07 Mar 2017, 08:00
Location: Austria

Re: Set the paper tray

Post by EwaldP » 11 May 2017, 06:17

Sorry for the late answer but this is a side project for me and in the meantime there a some work with higher priority. Thank you for your answers. Your suggested solutions are our usual approach to print papers on different trays but in a special case it would be helpful, to set the tray before printing with ShellExecute some pdfs.

I think it's not worth to invest more time. Thank you for your effort.
Ewald
Ewald P. Palmetshofer
EDV-Hausleitner GmbH
4020 Linz
www.edv-hausleitner.at

Return to “General Discussion”

Who is online

Users browsing this forum: Ccbot [Crawler] and 0 guests