Hanqian
asked on
How to print postscript file in dialog based application?
I have a postscript file need to be printed in a dialog application, I want to have print button
in the dialog window, when "Print" button is clicked,
print dialog starts, so user can choose the printer, font,
pages.... , then it prints the postscript file stored at my local directory. I don't need to view this file.
Thanks.
Hanqian
in the dialog window, when "Print" button is clicked,
print dialog starts, so user can choose the printer, font,
pages.... , then it prints the postscript file stored at my local directory. I don't need to view this file.
Thanks.
Hanqian
ASKER
I know how to start print diaplog, but I don't know how to let
printer know what file to print?
printer know what file to print?
ASKER
I have the following code, but I couldn't make it work.
// Print the doc.
CPrintDialog dlgPrint (FALSE, PD_ALLPAGES, this);
if (dlgPrint.DoModal() == IDOK) {
CDC dcPrint;
dcPrint.Attach (dlgPrint.GetPrinterDC ());
// Create and fill a DOCINFO structure
DOCINFO myPrintJob;
myPrintJob.cbSize = sizeof(m_sigImageLen);
myPrintJob.lpszDocName = tmpDocFile;
myPrintJob.lpszOutput = NULL;
myPrintJob.lpszDatatype = NULL;
myPrintJob.fwType = NULL;
// Start to print file.
if (dcPrint.StartDoc(&myPrint Job) >= 0) {
dcPrint.StartPage();
// dcPrint.TextOut(0,0,"My Samll Print Job");
dcPrint.EndPage();
dcPrint.EndDoc();
}
dcPrint.DeleteDC();
}
// Print the doc.
CPrintDialog dlgPrint (FALSE, PD_ALLPAGES, this);
if (dlgPrint.DoModal() == IDOK) {
CDC dcPrint;
dcPrint.Attach (dlgPrint.GetPrinterDC ());
// Create and fill a DOCINFO structure
DOCINFO myPrintJob;
myPrintJob.cbSize = sizeof(m_sigImageLen);
myPrintJob.lpszDocName = tmpDocFile;
myPrintJob.lpszOutput = NULL;
myPrintJob.lpszDatatype = NULL;
myPrintJob.fwType = NULL;
// Start to print file.
if (dcPrint.StartDoc(&myPrint
dcPrint.StartPage();
// dcPrint.TextOut(0,0,"My Samll Print Job");
dcPrint.EndPage();
dcPrint.EndDoc();
}
dcPrint.DeleteDC();
}
ASKER
I have the following code, but I couldn't make it work from here.
How to link postscript file to printer?
// Print the doc.
CPrintDialog dlgPrint (FALSE, PD_ALLPAGES, this);
if (dlgPrint.DoModal() == IDOK) {
CDC dcPrint;
dcPrint.Attach (dlgPrint.GetPrinterDC ());
// Create and fill a DOCINFO structure
DOCINFO myPrintJob;
myPrintJob.cbSize = sizeof(?);
myPrintJob.lpszDocName = FileName;
myPrintJob.lpszOutput = NULL;
myPrintJob.lpszDatatype = NULL;
myPrintJob.fwType = NULL;
// Start to print file.
if (dcPrint.StartDoc(&myPrint Job) >= 0) {
// Don't know waht to add here??
dcPrint.EndDoc();
}
dcPrint.DeleteDC();
}
How to link postscript file to printer?
// Print the doc.
CPrintDialog dlgPrint (FALSE, PD_ALLPAGES, this);
if (dlgPrint.DoModal() == IDOK) {
CDC dcPrint;
dcPrint.Attach (dlgPrint.GetPrinterDC ());
// Create and fill a DOCINFO structure
DOCINFO myPrintJob;
myPrintJob.cbSize = sizeof(?);
myPrintJob.lpszDocName = FileName;
myPrintJob.lpszOutput = NULL;
myPrintJob.lpszDatatype = NULL;
myPrintJob.fwType = NULL;
// Start to print file.
if (dcPrint.StartDoc(&myPrint
// Don't know waht to add here??
dcPrint.EndDoc();
}
dcPrint.DeleteDC();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Do I need to add some header file?, it complains function:
OpenPrinter(),
StartDocPrinter(),
WritePrinter(),
EndDocPrinter(),
ClosePrinter(),
are undeclared identifiers.
Thanks.
Hanqian
OpenPrinter(),
StartDocPrinter(),
WritePrinter(),
EndDocPrinter(),
ClosePrinter(),
are undeclared identifiers.
Thanks.
Hanqian
<windows.h>
But I don't understand. If DOCINFO is defnied, these functions also should be defined.
But I don't understand. If DOCINFO is defnied, these functions also should be defined.
ASKER
Right now I hard code the name of printer, it works well.
Thanks a lot.
BTW if it doesn't take your much time,
do you know how to get name of the default printer for this function
OpenPrinter (defPrnName, &hPrinter, NULL)) ?
Thanks.
Hanqian
Thanks a lot.
BTW if it doesn't take your much time,
do you know how to get name of the default printer for this function
OpenPrinter (defPrnName, &hPrinter, NULL)) ?
Thanks.
Hanqian
Ask another question (for only a few points if you don't have much) and I'll tell you.
(Just that if someone searches through question titles, should find the solution for that question.)
(Just that if someone searches through question titles, should find the solution for that question.)
Or do you want us to do all the programming work instead of you?