Link to home
Start Free TrialLog in
Avatar of Hanqian
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
 
Avatar of joghurt
joghurt

What is your exact problem? What are the steps where you're stuck?
Or do you want us to do all the programming work instead of you?
Avatar of Hanqian

ASKER

I know how to start print diaplog, but I don't know how to let
printer know what file to print?
Avatar of Hanqian

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(&myPrintJob) >= 0) {
                        dcPrint.StartPage();
                  //      dcPrint.TextOut(0,0,"My Samll Print Job");
                        dcPrint.EndPage();
                        dcPrint.EndDoc();
                  }
                  dcPrint.DeleteDC();
            }
Avatar of Hanqian

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(&myPrintJob) >= 0) {
              // Don't know waht to add here??
      dcPrint.EndDoc();
      }
      dcPrint.DeleteDC();
}
ASKER CERTIFIED SOLUTION
Avatar of joghurt
joghurt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hanqian

ASKER

Do I need to add some header file?, it complains function:
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.
Avatar of Hanqian

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
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.)