Set custom printer paper size.

The place to discuss FoxPro issues not directly related to ProMatrix.

Set custom printer paper size.

Postby btiguy » Mon Nov 10, 2014 1:07 pm

My customers use thermal printers where the paper width is about 3.5" wide. How do I set the report custom size in VFP9.0?
TIA
Don
btiguy
 
Posts: 455
Joined: Mon Jun 21, 2010 4:03 pm

Re: Set custom printer paper size.

Postby stecenko » Mon Nov 10, 2014 3:12 pm

You set the custom paper size for that printer in Windows, using the control panel. In VFP you then select the printer in page setup and the new custom paper size appears as an option for that printer.
Richard Stecenko
Interactive Computer Services Inc.
Victoria, British Columbia
204.453.2052
stecenko
 
Posts: 822
Joined: Mon Jun 21, 2010 8:06 pm
Location: Saanich, British Columbia

Re: Set custom printer paper size.

Postby btiguy » Mon Nov 10, 2014 5:24 pm

Ooh! I don't have the same printer as my client. They have a thermal printer, maybe Zebra, but not sure. In any case, I can't do what you suggest...I don't think. Or am I wrong. I don't think I can install the drivers without the printer. I assume the paper sizes are within the drivers?? I'll need to get more info from the customer.
TIA
Don
btiguy
 
Posts: 455
Joined: Mon Jun 21, 2010 4:03 pm

Re: Set custom printer paper size.

Postby stecenko » Mon Nov 10, 2014 6:55 pm

You can create a custom paper size for any printer. You can create it on your computer for testing. You may have to fiddle with it at your client's location.
Richard Stecenko
Interactive Computer Services Inc.
Victoria, British Columbia
204.453.2052
stecenko
 
Posts: 822
Joined: Mon Jun 21, 2010 8:06 pm
Location: Saanich, British Columbia

Re: Set custom printer paper size.

Postby stecenko » Mon Nov 10, 2014 6:58 pm

The other problem you're going to run into is that normally you print to the default printer. If you client has more than one printer installed, then this Zebra may not be the default. So at the client's location you may have to use the Report Manager to edit the report to expose Printer Setup and then choose the printer there.
Richard Stecenko
Interactive Computer Services Inc.
Victoria, British Columbia
204.453.2052
stecenko
 
Posts: 822
Joined: Mon Jun 21, 2010 8:06 pm
Location: Saanich, British Columbia

Re: Set custom printer paper size.

Postby DavidLeMesurier » Tue Nov 11, 2014 2:03 pm

I get around the printing to the default printer like this and it seems to work OK


The ini file it uses looks like this

[Printer]
A4=Adobe PDF
Animal ID Label=Adobe PDF
Lab Label=Adobe PDF
Drug Label=Adobe PDF
INVOICE=Adobe PDF
LAB A4=Adobe PDF
PLASTIC=Adobe PDF

This gets set by the user in a form that they select the printer they want to use for the various output types.
Stores as local ini file so it is machine specfic



All my reports are printed via a call to this :
*** Copyright Avian Management Services 2007-- {^2007-07-18 18:51:34}

#IF .F.
TEXT
********************************
* HELP BUILDER COMMENT BLOCK *
********************************
*:Help Documentation
*:Name: Preclass.Print_Generic_Report

*:Purpose:

*:Keywords:

*:Parameters:
tcReportName: The name of the report to run
tcPrinter: The ini printer you want to set, if any
tcPageCaption: The caption of the page with this report if previewing multiple reports
tlUseXFRX: T. to use xfrf. If .F. then the report will just print as normal
*:Returns:

*:Remarks:

*:Example:

*:EndHelp
ENDTEXT
#ENDIF
LPARAMETERS tcReportName,tcPrinter,tcPageCaption,tlUseXFRX
LOCAL lcReportName, lcPrinter, lcPageCaption, llUseXFRX, loPreview, loViewer, loxfrx, lnRetval


lcReportName = Param_Val(tcReportName,'')
lcPrinter = Param_Val(tcPrinter,'')
lcPageCaption = Param_Val(tcPageCaption,'')
llUseXFRX = Param_Val(tlUseXFRX,.F.)

IF !EMPTY(lcPrinter)
TRY
_screen.oApp.Set_ini_Printer(lcPrinter)
CATCH
_screen.oApp.Set_ini_Printer('')
ENDTRY
ENDIF


IF llUseXFRX
loPreview = CREATEOBJECT("frmMPPreviewer")
loPreview.iEmail = 0 && Hide the email icon

loxfrx = XFRX("XFRX#LISTENER")
loxfrx.initLog()
lnRetval = loxfrx.SetParams(,,,,,,"XFF")

IF lnRetval = 0

REPORT FORM &lcReportName OBJECT loxfrx

loPreview.previewXFF(loxfrx.oxfdocument,lcPageCaption)
IF loPreview.VISIBLE = .F.
loPreview.SHOW(1)
ENDIF
ELSE

this.xFrx_Error(lnRetVal)

ENDIF

ELSE
REPORT FORM &lcReportName NOCONSOLE TO PRINTER
ENDIF

loPreview = .NULL.
loxfrx = .NULL.

**Reset to the default printer
_screen.oApp.Set_ini_Printer('')






****************************************************************************************************

*** Copyright Avian Management Services 2008-- {^2008-08-19 13:49:27}
*
*** {^2008-08-19 13:49:27}
*** Copyright Avian Management Services 2008
*** {2008-08-19 13:49:30}
#IF .F.
TEXT
********************************
* HELP BUILDER COMMENT BLOCK *
********************************
*:Help Documentation
*:Name:
DEVAPP.SET_INI_PRINTER
*:Purpose:

*:Keywords:

*:Parameters:

*:Returns:

*:Remarks:
Moved from devpre class to devapp class
*:Example:

*:EndHelp
ENDTEXT
#ENDIF


LPARAMETERS tcprintername, tcinifile, tcsection


LOCAL llReRetVal
STORE .F. TO llReRetVal

PRIVATE lcprintername,lcinifile,lcsection

lcprintername = Param_Val(tcprintername,'')
lcprintername = UPPER(ALLTRIM(lcprintername))

lcinifile = Param_Val(tcinifile,'Printer.ini')
lcsection = Param_Val(tcsection,'Printer')

IF EMPTY(lcprintername)
STORE .T. TO llReRetVal
THIS.set_default_printer(THIS.cOldPrinter)
ELSE
TRY
THIS.cOldPrinter = THIS.get_default_printer()
lcprintername = get_ini(lcsection,lcprintername,lcinifile)

IF !EMPTY(lcprintername)
llReRetVal = THIS.set_default_printer(lcprintername)
ELSE
THIS.set_default_printer(THIS.cOldPrinter)
llReRetVal = .F.
ENDIF
CATCH
Alert_Msg('Unable to set ini printer',,,,.T.)
ENDTRY

IF !llReRetVal
THIS.set_default_printer(THIS.cOldPrinter)
ENDIF
ENDIF

Return llReRetVal

******************************************************************************
*** Copyright Avian Management Services 2008-- {^2008-08-19 14:09:04}
*
*** {^2008-08-19 14:09:04}
*** Copyright Avian Management Services 2008
*** {2008-08-19 14:09:06}
#IF .F.
TEXT
********************************
* HELP BUILDER COMMENT BLOCK *
********************************
*:Help Documentation
*:Name:
DEVAPP.SET_DEFAULT_PRINTER
*:Purpose:

*:Keywords:

*:Parameters:

*:Returns:

*:Remarks:

*:Example:

*:EndHelp
ENDTEXT
#ENDIF


LPARAMETERS tcPrinter

LOCAL lcPrinter, llRetVal,lnPrinterSetValue
STORE .T. TO llRetVal

lcPrinter = Param_Val(tcPrinter,'')

IF EMPTY(lcPrinter)
lcPrinter = THIS.cDefaultPrinter
ELSE
THIS.cdefaultprinter = THIS.Get_Default_Printer()
ENDIF

IF EMPTY(THIS.cdefaultprinter)
THIS.cdefaultprinter = THIS.coriginalprinter
ENDIF

** set it to the original default printer if it's empty
IF EMPTY(lcPrinter)
lcPrinter = THIS.coriginalprinter
endif

lcPrinter = ALLTRIM(lcPrinter)

IF !EMPTY(lcPrinter) AND lcPrinter <> [''] && no point in trying to set it to an empty printer name
DECLARE INTEGER SetDefaultPrinter IN winspool.drv;
STRING pszPrinter

lnPrinterSetValue = SetDefaultPrinter(lcPrinter)

IF lnPrinterSetValue = 0
DECLARE INTEGER GetLastError IN kernel32
lnLastError = GetLastError()
Alert_Msg('Unable to set printer in Set Default Printer. Error code from Windows is ' + ALLTRIM(STR(lnLastError) + 'Printer name is' + ' ' + lcPrinter),,,,.T.)
llRetVal = .F.
ENDIF

ENDIF

RETURN llRetVal

***********************************************
*** Copyright Avian Management Services 2008-- {^2008-08-19 14:12:18}
*
*** {^2008-08-19 14:12:18}
*** Copyright Avian Management Services 2008
*** {2008-08-19 14:12:20}
#IF .F.
TEXT
********************************
* HELP BUILDER COMMENT BLOCK *
********************************
*:Help Documentation
*:Name:
DEVAPP.GET_DEFAULT_PRINTER
*:Purpose:

*:Keywords:

*:Parameters:

*:Returns:

*:Remarks:

*:Example:

*:EndHelp
ENDTEXT
#ENDIF


DECLARE INTEGER GetDefaultPrinter IN winspool.drv;
STRING @pszBuffer, INTEGER @pcchBuffer

* may not be supported on Win9*/Me
LOCAL lcPrinter, lnBufsize
lnBufsize = 250
lcPrinter = REPLICATE(CHR(0), lnBufsize)
TRY
IF GetDefaultPrinter(@lcPrinter, @lnBufsize) <> 0
lcPrinter = SUBSTR(lcPrinter, 1,AT(Chr(0),lcPrinter)-1)
ELSE
ASSERT .F. MESSAGE 'Unable to get default Printer'
*Alert_Msg('Unable to get default Printer',,,,.T.)
lcPrinter=""
ENDIF
CATCH
ASSERT .F. MESSAGE 'Unable to get default Printer'
*Alert_Msg('Unable to get default Printer',,,,.T.)
lcPrinter=""
ENDTRY
RETURN lcPrinter
DavidLeMesurier
 
Posts: 82
Joined: Sun Jun 13, 2010 12:43 am
Location: Dubai

Re: Set custom printer paper size.

Postby cti2 » Wed Nov 12, 2014 12:38 pm

Hi Don:
I have set up printing for many Zebra printers so here's some ideas
In order to set this up correctly - you don't need to have the physical printer.
You can download and install the driver for the given printer and program for it without having it.
Go into the new driver and set the label size to match what your customer will have, apply and save.
Go back into the driver and double check that it was happy (retained) you label size.
Set your default windows printer to the specific driver.
When working in the VFP label designer (MODI LABEL xxxxxx) go to file menu > page setup > select the zebra printer and save.
When you are done and save, you then need to clean out the tags by USEING the LBX file, browsing, then completely clear out the Expr, tag & tag2 fields for ObjType = 53 , close out of browse. This removes and info about the printer environment that may have been saved.
At your customer's location, if the Zebra is not the windows default, you need to use code In you VFP/VPM program to switch back and forth, using SET PRINTER TO NAME xxxxx where xxxx is the name of the zebra printer.
Then after sending output to the Zebra, you should switch back to the default by using SET PRINTER TO NAME - again.
HTH, be patient, Pete Ryder
cti2
 
Posts: 181
Joined: Wed Oct 13, 2010 6:38 am


Return to Visual FoxPro

Who is online

Users browsing this forum: No registered users and 1 guest

cron