1XmPrintToFile(library call)                        XmPrintToFile(library call)
2
3
4

NAME

6       XmPrintToFile — Retrieves and saves data that would normally be printed
7       by the X Print Server.
8

SYNOPSIS

10       #include <Xm/Print.h>
11       XtEnumXmPrintToFile(
12       Display*dpy,
13       Stringfilename,
14       XPFinishProcfinish_proc,
15       XtPointerclient_data);
16

DESCRIPTION

18       XmPrintToFile hides the details of X display connection and  XpGetDocu‐
19       mentData to the Motif application programmer.
20
21       This  function is a convenience routine that hides the details of the X
22       and Xp internals to the application programmer by calling the XpGetDoc‐
23       umentData function with appropriate save and finish callbacks.
24
25       This  is  used in the context of X Printing when the user has specified
26       the "print-to-file" option from a regular Print Setup Dialog box.
27
28       XmPrintToFile first tries to open the given filename  for  writing  and
29       returns  False if it can't.  Else, it uses XpGetDocumentData, giving it
30       a save proc that writes the data received in the file and a finish proc
31       that  closes the file or removes it on an unsuccessful termination.  It
32       calls finish_proc at that point, passing it the argument received  from
33       the  Xp  layer  (status == XPGetDocFinished means the file is valid and
34       was closed, otherwise the file was removed).
35
36       XmPrintToFile is non-blocking; if  it  returns  successfully,  it  just
37       means  the  file  was  opened  successfully,  not that all the data was
38       received.
39
40       dpy       Print display connection.
41
42       filename  Name of the file to put the print data in.
43
44       finish_proc
45                 Called when all the data has been received.
46
47       client_data
48                 Passed with the finish_proc.
49

RETURN VALUE

51       Returns False if the filename could not be created or opened for  writ‐
52       ing, True otherwise.
53

ERRORS/WARNINGS

55       Not applicable
56

EXAMPLES

58       A typical OK callback from a DtPrintSetupBox:
59
60       PrintOKCallback(widget...)
61       /*-------------*/
62       {   int save_data = XPSpool;
63
64           pshell = XmPrintSetup (widget, pbs->print_screen,
65                                          "Print", NULL, 0);
66
67           XtAddCallback(pshell, XmNstartJobCallback, startJobCB, data);
68
69           if (pbs->destination == DtPRINT_TO_FILE)
70                        save_data = XPGetData;
71
72           /* start job must precede XpGetDocumentData in XmPrintToFile */
73           XpStartJob(XtDisplay(pshell), save_data);
74           XFlush(XtDisplay(pshell));  /* maintain the sequence
75                                        between startjob and getdocument */
76
77           /* setup print to file */
78           if (pbs->destination == DtPRINT_TO_FILE)
79               XmPrintToFile(XtDisplay(pshell),
80                                        pbs->dest_info, FinishPrintToFile, NULL);
81           }
82
83       }
84
85       static void
86       startJobCB(Widget, XtPointer call_data, XtPointer client_data)
87       {
88         print(p);   /* rendering happens here */
89
90         XpEndJob(XtDisplay(p->print_shell));
91
92         /* clean up */
93         XtDestroyWidget(p->print_shell);
94                 XtCloseDisplay(XtDisplay(p->print_shell));
95       }
96

SEE ALSO

98       XmPrintSetup(3),  XmPrintShell(3),  XmRedisplayWidget(3), XmPrintPopup‐
99       PDM(3)
100
101
102
103                                                   XmPrintToFile(library call)
Impressum