YOUSEFUL / FILEMAKER

YsflPrint — function reference

FAQ, examples and tutorial

Function prefix YsflPr_, 16 functions. Windows only (spooler APIs). All failures return ? message; the Win32 code is available through YsflPr_LastError / YsflPr_LastErrorText.

FileMaker's Print [With dialog: Off] uses the current default printer and that printer's per-user driver defaults. YsflPrint steers both: pick the printer, set its defaults, print, then restore.

Typical script

Example
Set Variable [ $saved ; YsflPr_Save ]
Set Variable [ $r ; YsflPr_Prepare ( "Label Printer" ; "orientation=landscape¶copies=2¶tray=Tray 2" ) ]
Print [ With dialog: Off ]
Set Variable [ $r ; YsflPr_Restore ( $saved ) ]

Settings format

-separated key=value lines. Keys are case-insensitive.

key values
copies 1 … n
orientation portrait, landscape
paper a name from YsflPr_GetSetting ( p ; "papers" )
tray a name from YsflPr_GetSetting ( p ; "trays" )
duplex off, long, short
color mono, color
collate 0, 1
quality draft, low, medium, high, or a DPI number

Unknown keys, or paper/tray names the driver does not offer, fail with ? Unknown setting: k, ? Unknown paper: x, ? Unknown tray: x. Values are validated by the driver before they are saved, so a driver may silently normalise an unsupported value (for example duplex on a simplex printer).

Functions

Function Params Returns
YsflPr_Version YsflPrint v.1.0.0
YsflPr_Register ( {option} ) Registered.
YsflPr_LastError / YsflPr_LastErrorText last failure code / text
YsflPr_ListPrinters ( {options} ) details printer names, one per line; with details: `name
YsflPr_GetDefault default printer name
YsflPr_SetDefault ( printerName ) 0
YsflPr_Prepare ( printerName ; {settings} ) 0; makes the printer the default and applies settings; empty name = current default
YsflPr_GetSetting ( printerName ; attribute ) any settings key, papers, trays, driver, port, location, comment, status, jobs, isdefault value
YsflPr_SetSettings ( printerName ; settings ) 0; persists the per-user driver defaults
YsflPr_Save token with the default printer and its settings
YsflPr_Restore ( token ) 0; restores the default printer and its settings
YsflPr_Status ( printerName ) ready, or a comma list such as offline,paperout
YsflPr_JobCount ( printerName ) queued jobs
YsflPr_CancelJobs ( printerName ) 0; purges the queue (may need admin rights on some queues)
YsflPr_PdfPrinter name of the Microsoft Print to PDF printer, or ""

Status words: offline, paused, error, paperjam, paperout, dooropen, busy, printing, warmingup, tonerlow, notoner, userintervention, outofmemory, pageunderway, deleting, initializing, notavailable, waiting, processing, manualfeed, paperproblem, ioactive, binfull, serverunknown, powersave.

Not in v1

Silent print-to-PDF with a chosen file name (the Microsoft driver prompts unless its port is reconfigured, which needs admin rights), driver-private options (staple, punch), printer installation.