XMPRINTTOFILE(3)
π NAME π
XmPrintToFile β the library call that grabs all the data that would normally get printed by the X Print Server and, like, saves it for you π
β¨ SYNOPSIS β¨
#include <Xm/Print.h>
XtEnumXmPrintToFile(
Display*dpy,
Stringfilename,
XPFinishProcfinish_proc,
XtPointerclient_data);
π¦ DESCRIPTION π¦
okay so, XmPrintToFile is literally here to hide all the X display connection drama and the XpGetDocumentData details from you, the Motif application programmer. no cap. you don't need to know the lore, she's got it handled π
She's a convenience routine, bestie β the whole point is that she wraps up the X and Xp internals for you by calling the XpGetDocumentData function with the appropriate save and finish callbacks already wired in. iconic behavior, honestly.
You use this in the context of X Printing when the user has picked the "print-to-file" option from a regular Print Setup Dialog box. very demure, very mindful.
Here's the flow, and it's actually pretty simple:
- First,
XmPrintToFiletries to open the given filename for writing, and if it can't, she returnsFalse. periodt. - Otherwise, she uses
XpGetDocumentData, handing it a save proc that writes the data received into the file, plus a finish proc that closes the file β or removes it if the termination wasn't successful. π«Ά - Then she calls finish_proc right at that point, passing along the argument she got from the Xp layer. And listen:
status == XPGetDocFinishedmeans the file is valid and was closed. Anything else means the file was removed. π
β οΈ vibe check: XmPrintToFile is non-blocking. So if she returns successfully, that only means the file was opened successfully β it does not mean all the data has been received yet. don't get it twisted, bestie π
the arguments, one by one π
dpyβ the Print display connection. your whole display situation.filenameβ the name of the file to put the print data in. yeah, that one.finish_procβ called when all the data has been received. she's the closer πclient_dataβ passed along with the finish_proc. little gift, hand-delivered.
β RETURN VALUE β
- Returns
Falseif filename could not be created or opened for writing. - Returns
Trueotherwise. slay β¨
π ERRORS/WARNINGS π
Not applicable. nothing to see here, no drama, we love a clean section π
π₯ EXAMPLES π₯
Here's a typical OK callback from a DtPrintSetupBox, and yes she ate:
PrintOKCallback(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));
}
note the little comment in there, bestie: start job must precede XpGetDocumentData in XmPrintToFile. order matters, don't freestyle it π§
π SEE ALSO π
and that's the whole page, babe π¦ this was the XmPrintToFile(library call) manual page from the Motif library call docs β go forth and print to file responsibly, ily, mwah ππΈ
π¦ where this page comes from
- alpine 3.24: motif-doc 2.5.2-r0 Β· LGPL-2.1-or-later
- arch rolling: openmotif 2.3.8-4 Β· LGPL-2.1-or-later
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- epel 10: motif-devel 2.3.8-2.el10_2 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- nixos 26.05: motif 2.3.8
- nixpkgs unstable: motif 2.3.8
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms