Simple print question

Simple print question

Postby dtussman » Sun Jan 31, 2016 5:20 am

In old 2007 version of FWH you could say

print oprn name pname to (cprinter)

where cprinter was the name of an installed printer. Now with FWH 1507 it ignores the "to" clause and just goes to the default printer. I don't want the user to have to select the printer since I am using a PDF writer that I provide and its part of a complicated routine where I generate bills to pdf files and then email them to the respective recipients all without requiring any user input. How can I get it to work the old way?
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Simple print question

Postby dtussman » Sun Jan 31, 2016 5:33 am

Figured it out, setprintdefault(cprinter) is the answer.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Simple print question

Postby dtussman » Sun Jan 31, 2016 6:22 am

I take it all back. setprintdefault() seems to have no effect at all.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Simple print question

Postby Antonio Linares » Sun Jan 31, 2016 10:27 am

We are checking it.

Could other FWH users report if this is failing for them too ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Simple print question

Postby cnavarro » Sun Jan 31, 2016 10:40 am

dtussman wrote:In old 2007 version of FWH you could say

print oprn name pname to (cprinter)

where cprinter was the name of an installed printer. Now with FWH 1507 it ignores the "to" clause and just goes to the default printer. I don't want the user to have to select the printer since I am using a PDF writer that I provide and its part of a complicated routine where I generate bills to pdf files and then email them to the respective recipients all without requiring any user input. How can I get it to work the old way?


You are tried without brackets?

print oprn name pname to cprinter
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Simple print question

Postby dtussman » Sun Jan 31, 2016 6:39 pm

yes cnavarro, I tried everything!
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Simple print question

Postby dtussman » Mon Feb 01, 2016 2:44 am

I got it to work with the following code:

setprintdefault(cprinter)
oprn:=printbegin(pname,.f.,.f.,cprinter,.t.)
oprn:end()
print oprn name pname to cprinter

Only then does the program successfully change the default printer. If I leave off any of those lines it doesn't work.

Strange, but I suppose the fact that it works is all that matters.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Simple print question

Postby dtussman » Mon Feb 01, 2016 3:12 am

I now realize the source of my error. I was using prngetname() to check if I had successfully changed the default printer, but changing the default printer doesn't change prngetname(). Whew.
dtussman
 
Posts: 97
Joined: Sat Jun 06, 2015 6:57 pm

Re: Simple print question

Postby Antonio Linares » Mon Feb 01, 2016 9:53 am

Please try it this way:

setprintdefault(cprinter)
PrinterInit()
print oprn name pname to cprinter

SetPrintDefault() just changes the Windows registry values but does not refresh the FWH printer internals

Maybe we should call PrinterInit() from SetPrintDefault() automatically
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Simple print question

Postby James Bott » Mon Feb 01, 2016 8:56 pm

David,

Antonio's code works fine for me (using FWH 15.6 and under Windows 8.1).

Below is a little sample to test it.

Personally, I never change the default printer since the user may not want this behavior. I think it would be rude for any app to change the default printer. Users will be confused as to why the default was changed later when they are running a different app. Even it you restore it at the end of your app, the user could still switch to another app while yours was still open, then try to print.

Anyway, the way you were doing it originally should still work. If my little test doesn't work for you, then we need to find the problem. Let us know what you find.

James


Code: Select all  Expand view
#include "fivewin.ch"

Function Main()
  Local cPrinter:=  "PDFCreator" // Change to  your PDF driver
 
  msgInfo( prnGetName(), "Default Printer" )
 
  PRINTER oPrn NAME "My Report" TO cPrinter
 
  msgInfo( oPrn:cModel , "oPrn:cModel")
 
return nil

 
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 98 guests