How can I get a device context?

Hello,

Is it possible to get a Device Context from PDFCreator to insert it in the classical windows print methods ?

I’ve not find anywhere the information about the COM object …

I’ve also tried to simply open the printer to get the hDC like this :

        szPrinter = “PDFCreator”;
        if (!OpenPrinter(szPrinter, &hPrinter, NULL))
        {
            CString csMessage("");
            csMessage.Format(“Couldn’t open printer “%s”
“, szPrinter);
            AfxMessageBox( csMessage );
        }
        else
        {
            // Get the document settings.
            nSize = DocumentProperties(NULL, hPrinter, szPrinter, NULL, NULL, 0);
            pDevMode = (DEVMODE*) malloc(nSize);
            DocumentProperties(NULL, hPrinter, szPrinter, pDevMode, NULL, DM_COPY);
            DocumentProperties(NULL, hPrinter, szPrinter, pDevMode, pDevMode, DM_MODIFY | DM_PROMPT | DM_COPY);

            // Create device context.
            hDC = CreateDC(””, szPrinter, NULL, pDevMode);
            if (!hDC)
            {
                CString csMessage("");
                csMessage.Format("Couldn’t create device context for printer “%s”
", szPrinter);
                AfxMessageBox( csMessage );
            }
            else
            {
                // Begin a print job.
                docinfo.cbSize          = sizeof docinfo;
                docinfo.lpszDocName     = “PDF Test Document”;
                docinfo.lpszOutput      = “testPDFCreatorPrinter-graph.pdf”;
                docinfo.fwType          = 0;
                StartDoc(hDC, &docinfo);

                // Begin a page.
                StartPage(hDC);

                CDC *pPDF_DC = CDC::FromHandle(hDC);
                if (pPDF_DC)
                    {
                    pPDF_DC->m_bPrinting = 1;
                    CView::OnPrint( pPDF_DC, pInfo );
                    }

                // Terminate the page and the print job.
                EndPage(hDC);
                EndDoc(hDC);

                // Cleanup the document.
                DeleteDC(hDC);
                ClosePrinter(hPrinter);
                free(pDevMode);
            }
        }

        // uninitialize OLE libraries
        CoUninitialize();


But when I try to open my file Adobe Reader can’t open it !


Do you have any idea ?

Thanks in advance for any and all help.

Regards

Vincent