Blob Blame History Raw
'\" t
...\" PrtToFil.sgm /main/9 1996/10/02 11:49:29 cdedoc $
.de P!
.fl
\!!1 setgray
.fl
\\&.\"
.fl
\!!0 setgray
.fl			\" force out current output buffer
\!!save /psv exch def currentpoint translate 0 0 moveto
\!!/showpage{}def
.fl			\" prolog
.sy sed -e 's/^/!/' \\$1\" bring in postscript file
\!!psv restore
.
.de pF
.ie     \\*(f1 .ds f1 \\n(.f
.el .ie \\*(f2 .ds f2 \\n(.f
.el .ie \\*(f3 .ds f3 \\n(.f
.el .ie \\*(f4 .ds f4 \\n(.f
.el .tm ? font overflow
.ft \\$1
..
.de fP
.ie     !\\*(f4 \{\
.	ft \\*(f4
.	ds f4\"
'	br \}
.el .ie !\\*(f3 \{\
.	ft \\*(f3
.	ds f3\"
'	br \}
.el .ie !\\*(f2 \{\
.	ft \\*(f2
.	ds f2\"
'	br \}
.el .ie !\\*(f1 \{\
.	ft \\*(f1
.	ds f1\"
'	br \}
.el .tm ? font underflow
..
.ds f1\"
.ds f2\"
.ds f3\"
.ds f4\"
.ta 8n 16n 24n 32n 40n 48n 56n 64n 72n 
.TH "XmPrintToFile" "library call"
.SH "NAME"
\fBXmPrintToFile\fP \(em Retrieves and saves data that
would normally be printed by the X Print Server\&.
.SH "SYNOPSIS"
.PP
.nf
#include <Xm/Print\&.h>
\fBXtEnum\fBXmPrintToFile\fP\fR(
\fBDisplay\fB*dpy\fR\fR,
\fBString\fBfilename\fR\fR,
\fBXPFinishProc\fBfinish_proc\fR\fR,
\fBXtPointer\fBclient_data\fR\fR);
.fi
.SH "DESCRIPTION"
.PP
\fBXmPrintToFile\fP
hides the details of X display connection and
\fBXpGetDocumentData\fP
to the Motif application programmer\&.
.PP
This function is a convenience routine that hides
the details of the X and Xp internals to the
application programmer by calling the
\fBXpGetDocumentData\fP
function with appropriate save and finish callbacks\&.
.PP
This is used in the context of X Printing when
the user has specified the "print-to-file" option from
a regular Print Setup Dialog box\&.
.PP
\fBXmPrintToFile\fP
first tries to open the given filename for writing and returns
\fBFalse\fP
if it can\&'t\&.
Else, it uses
\fBXpGetDocumentData\fP, giving it a save proc that writes the
data received in the file and a finish proc that closes the
file or removes it on an unsuccessful termination\&.
It calls
\fBfinish_proc\fP
at that point, passing it the argument received from the
Xp layer (\fBstatus == XPGetDocFinished\fP
means the file is valid and was closed, otherwise the file was removed)\&.
.PP
\fBXmPrintToFile\fP is non-blocking; if it returns successfully, it
just means the file was opened successfully, not
that all the data was received\&.
.IP "\fIdpy\fP" 10
Print display connection\&.
.IP "\fIfilename\fP" 10
Name of the file to put the print data in\&.
.IP "\fIfinish_proc\fP" 10
Called when all the data has been received\&.
.IP "\fIclient_data\fP" 10
Passed with the \fIfinish_proc\fP\&.
.SH "RETURN VALUE"
.PP
Returns \fBFalse\fP
if the filename could not be created or opened for writing,
\fBTrue\fP otherwise\&.
.SH "ERRORS/WARNINGS"
.PP
Not applicable
.SH "EXAMPLES"
.PP
A typical OK callback from a
\fBDtPrintSetupBox\fP:
.PP
.nf
\f(CWPrintOKCallback(widget\&.\&.\&.)
/*-------------*/
{   int save_data = XPSpool;

    pshell = XmPrintSetup (widget, pbs->print_screen,
                                   "Print", NULL, 0);

    XtAddCallback(pshell, XmNstartJobCallback, startJobCB, data);

    if (pbs->destination == DtPRINT_TO_FILE)
                 save_data = XPGetData;

    /* start job must precede XpGetDocumentData in XmPrintToFile */
    XpStartJob(XtDisplay(pshell), save_data);
    XFlush(XtDisplay(pshell));  /* maintain the sequence
                                 between startjob and getdocument */

    /* setup print to file */
    if (pbs->destination == DtPRINT_TO_FILE)
        XmPrintToFile(XtDisplay(pshell),
                                 pbs->dest_info, FinishPrintToFile, NULL);
    }

}

static void
startJobCB(Widget, XtPointer call_data, XtPointer client_data)
{
  print(p);   /* rendering happens here */

  XpEndJob(XtDisplay(p->print_shell));

  /* clean up */
  XtDestroyWidget(p->print_shell);
          XtCloseDisplay(XtDisplay(p->print_shell));
}\fR
.fi
.PP
.SH "SEE ALSO"
.PP
\fBXmPrintSetup\fP(3),
\fBXmPrintShell\fP(3),
\fBXmRedisplayWidget\fP(3),
\fBXmPrintPopupPDM\fP(3)
...\" created by instant / docbook-to-man, Sun 22 Dec 1996, 20:28