-
March 25th, 2010, 04:36 AM
#1
Printing using Win32 Printer.
Hi ,
I have a problem printing using win32 printer to "Adobe PDF" printer ( Which generates output in pdf format)
But the same code prints well with all other printers like Freepdf , Primopdf,ConvertWIZ , hardware printer..etc...
When i select the "Adobe PDF" to print the document the "StartDoc" returns -1.
but for the other printers "StartDoc" returns value > 0
I have attached the sample code below.
Code:
HGLOBAL hDevMode;
DEVMODE* pDevMode;
HDC hPrinterDC;
DOCINFO DocumentInfo;
hDevMode = GlobalAlloc(GHND, sizeof(DEVMODE));
if ( hDevMode )
{
// lock the memory and return a pointer to it
pDevMode = (DEVMODE *) GlobalLock(hDevMode);
if ( pDevMode )
{
// set the size of the DEVMODE structure
pDevMode->dmSize = sizeof(DEVMODE);
pDevMode->dmOrientation = DMORIENT_LANDSCAPE
pDevMode->dmPaperSize = m_pPrintSetupParams->iPaperMediaID ;
// tell Windows that I will be setting the dmOrientation and paper size ;
pDevMode->dmFields = DM_ORIENTATION | DM_PAPERSIZE ;
}
// unlock the memory for other functions to use this
GlobalUnlock(hDevMode);
}
hPrinterDC = CreateDC("WINSPOOL\0", pszPrinterName.c_str(),NULL,pDevMode);
memset( &DocumentInfo, 0, sizeof(DOCINFO) );
DocumentInfo.cbSize = sizeof(DOCINFO);
DocumentInfo.lpszDocName = "TestPage" ;
DocumentInfo.lpszOutput = (LPTSTR) NULL;
DocumentInfo.lpszDatatype = (LPTSTR) NULL;
DocumentInfo.fwType = 0;
int nError = StartDoc(hPrinterDC, &DocumentInfo); // The return value of this function is -1 with "Adobe PDF " printer.
if (nError == SP_ERROR)
{
return false;
}
The "Adobe PDF " printer will get installed with the installation of "Adobe Acrobat 9 Standard"
Plz help, Thanks in advance.
Regards,
Vijay.
Last edited by Marc G; March 25th, 2010 at 07:44 AM.
Reason: Added code tags
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|