Printing a 3D view

Dear all,

OpenCascade provides some methods to produce plotter or printer output. For WinNT I chose the following approach: - Open a print dialog. - Retrieve the settings made by the user. - Create a device driver. - Create a GIF and an enhanced meta file using method ScreenCopy. - Spool the meta file.

The process creates a perfect GIF and also produces an EMF which is then sent to the printer. The problem is that the EMF obviously only contains white (or transparent?) pixels which results in white sheets of paper spit out by the printer.

Does anybody have an idea what is going wrong?

Here is a code sample:

void myAppView::OnViewPrint() {

CPrintDialog dlg(FALSE, PD_ALLPAGES | PD_HIDEPRINTTOFILE ,NULL);

if (dlg.DoModal() == IDOK) {

CString theDevice = dlg.GetDeviceName();

Standard_Integer copies = dlg.GetCopies();

LPDEVMODE devmode = dlg.GetDevMode();

Standard_Real scale = devmode->dmScale;

Standard_Integer orientation = devmode->dmOrientation;

enum WNT_OrientationType casOrient;

switch (orientation) {

case DMORIENT_PORTRAIT:

casOrient = WNT_OT_PORTRAIT;

break;

case DMORIENT_LANDSCAPE:

casOrient = WNT_OT_LANDSCAPE;

break;

}

Handle(WNT_DDriver) myWNTDriver = new WNT_DDriver((Standard_CString)(LPCTSTR)theDevice,"spool.ps",casOrient,scale,copies);

myView->ScreenCopy(myWNTDriver,Standard_True,scale); // V3d_View.cxx

myWNTDriver->Spool(Aspect_PM_NPLOTTER,(Standard_CString)(LPCTSTR)theDevice,Standard_True);

myWNTDriver->Close();

} }

Thanks in advance for any hint!

Thomas

Liu Ailin's picture

Hi,

I try to apply this code in my program to print 3d view, but fail to arouse any response from the printer. I even use below code. The printer reject to print still.
.
.
.
Standard_Boolean ok=myWNTDriver->Spool(Aspect_PM_NPLOTTER,(Standard_CString)(LPCTSTR)theDevice,Standard_True);
myView->Print(NULL,Standard_True,Standard_False,(Standard_CString)(LPCTSTR)theDevice);
.
.
(ok is true.)

Where is the problem?

Thanks.

Liu