Page 1 of 1

Not getting "PDFXC3_StartDoc" from 64 Bit printer

Posted: Fri Jan 19, 2007 7:54 pm
by pwechter
My Visual C++ 6.0 application is not receiving the "PDFXC3_StartDoc" from the 64 Bit printer driver running on Windows Vista. This is working fine with 32 bit Vista.

Here is how I have it coded:

static nWM_PDFDOC_START3 =::RegisterWindowMessage("PDFXC3_StartDoc");
static nWM_PDFDOC_END3 = ::RegisterWindowMessage("PDFXC3_EndDoc");
static nWM_PDFDOC_DOCSAVED3 = ::RegisterWindowMessage("PDFXC3_DocSaved");
.
.
.
ON_REGISTERED_MESSAGE(nWM_PDFDOC_START3, OnPDFDocStart3)
ON_REGISTERED_MESSAGE(nWM_PDFDOC_END3, OnPDFDocEnd3)
ON_REGISTERED_MESSAGE(nWM_PDFDOC_DOCSAVED3, OnPDFDocSaved3)
.
.
.
LRESULT CMainFrame::OnPDFDocStart3(WPARAM wParam, LPARAM lParam)
{
HKEY hKey;
DWORD dRes;
DWORD desire;
CString sKeyname;
CString sKey;
CString app("None");

sKeyname.Format("Software\\Tracker Software\\PDF-XChange 3.0\\Drivers\\Control\\%.8lx", lParam);

dRes = RegCreateKeyEx(HKEY_CURRENT_USER, sKeyname, 0, NULL, 0, KEY_WRITE, NULL, &hKey, &desire);

if (dRes != ERROR_SUCCESS)
return 0;

RegSetValueEx(hKey, "Save.FullFileName", 0, REG_SZ, (BYTE*)(const char*)theApp.m_csPDFPathName,
theApp.m_csPDFPathName.GetLength() + 1);
RegSetValueEx(hKey, "Save.ShowSaveDialog", 0, REG_SZ, (LPBYTE)"No", 3);
RegSetValueEx(hKey, "Save.WhenExists", 0, REG_SZ, (LPBYTE)"Overwrite", 10);
RegSetValueEx(hKey, "Save.App.Run", 0, REG_SZ, (LPBYTE)(LPCSTR)app, app.GetLength() + 1);
RegSetValueEx(hKey, "Save.Type", 0, REG_SZ, (LPBYTE)(LPCSTR)"2", 3);
sKey = "MY KEY?????????????";
RegSetValueEx(hKey, "Reg.Key", 0, REG_SZ, (LPBYTE)(LPCSTR)sKey, sKey.GetLength() + 1);
sKey = "MY OTHER KEY?????????";
RegSetValueEx(hKey, "Reg.DevCode", 0, REG_SZ, (LPBYTE)(LPCSTR)sKey, sKey.GetLength() + 1);
RegCloseKey(hKey);

theApp.m_bPDFXCDocSaved = false;

return 1;
}



[/code]

Posted: Sun Jan 21, 2007 12:24 pm
by John - Tracker Supp
Hi,

On first looking at your code - it looks fine.

Could I ask you to please try the supplied C++ example and advise if this functions correctly - this will indicate if all has installed ok and if so the problem would appear to be in your application - in which case we would need a small example that fails to function - both source code and compiled project with any supporting files.

Please zip any files uploaded or emailed or they will be 'stripped' from your message.

Also please do not include your license keys in any sample.

thanks.

"supplied C++ example"

Posted: Mon Jan 22, 2007 4:02 pm
by pwechter
Hi,

I don't see the supplied C++ example in your posting. Does this mean I should look for an example in the SDK?

Thanks,
Peter

Posted: Mon Jan 22, 2007 6:49 pm
by John - Tracker Supp
Hi,

Assuming you have the SDK download - you should have this already, however - please find all relevant API examples attached.

HTH

Sample app works okay but is different

Posted: Mon Jan 22, 2007 10:13 pm
by pwechter
Hi John,

The sample app works okay but uses ShellExecute to do its printing. We use the same drawing code that is used with any other printer driver. The funny thing is that the program is receiving the PDFXC3_DocSaved message but not the PDFXC3_DocStart or PDFXC3_DocEnd messages.

The program selects the printer driver, sets the receips key and then waits until the printing is complete to reset the receips key. Below is the code I use to get the printing going. Please note there is a message loop in it which waits for the PDF to be created. Do you have any samples that look like this because I don't think I made this part up myself?

// Create an PDFXChange Printer device
HGLOBAL hSaveDevNames;
HGLOBAL hSaveDevMode;
PRINTDLG PrintDlg;

theApp.GetPrinterDeviceDefaults(&PrintDlg);
hSaveDevNames = PrintDlg.hDevNames;
hSaveDevMode = PrintDlg.hDevMode;

HGLOBAL hDevNames = CreatePdfWriterDevNames();
HGLOBAL hDevMode = hSaveDevMode;

// Set current device to PDFXChange Printer
theApp.SelectPrinter(hDevNames, hDevMode, FALSE);

if (theApp.GetIsPDFXChangeInstalled())
{
// For PDF-XChange make sure that the file is not open in another process
CFile pdfFile;
CFileException pdfFileException;
if (theApp.FileExists(lpszPathName))
{
if (!pdfFile.Open(lpszPathName, CFile::shareExclusive, &pdfFileException))
{
CString csError;
csError.Format("%s %d","File could not be opened for error reason:", pdfFileException.m_cause);
AfxMessageBox(PRUIE_PDF_OUTPUT_FILE_BUSY, MB_OK,0);
bCannotOutput = true;
rv = FALSE;
}
else
pdfFile.Close();
}


if (!bCannotOutput && theApp.GetPDFXChangeVersion() == 30)
{
dRes = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Tracker Software\\PDF-XChange 3.0\\Drivers\\Control\\Receips",
0, NULL, 0, KEY_WRITE, NULL, &hKey, &desire);
if (hKey != NULL)
{
RegSetValueEx(hKey, "Presto", 0, REG_DWORD, (LPBYTE)&AfxGetMainWnd()->m_hWnd, sizeof(DWORD));
RegCloseKey(hKey);
}
}
}

// Create PDF file for document using PDF Writer
if (!bCannotOutput)
rv = pView->PrintPdfFile(this);

if (theApp.GetIsPDFXChangeInstalled() && theApp.GetPDFXChangeVersion() == 30)
while (!theApp.m_bPDFXCDocSaved)
{
MSG msg;
while (::PeekMessage(&msg, AfxGetMainWnd()->GetSafeHwnd(), 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
continue;
}

if (theApp.GetIsPDFXChangeInstalled() && theApp.GetPDFXChangeVersion() == 30)
{
dRes = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Tracker Software\\PDF-XChange 3.0\\Drivers\\Control\\Receips",
0, NULL, 0, KEY_WRITE, NULL, &hKey, &desire);
if (hKey != NULL)
{
RegDeleteValue(hKey, "Presto");
RegCloseKey(hKey);
}
}

// Reselect current printer
theApp.SelectPrinter(hSaveDevNames, hSaveDevMode);

Posted: Tue Jan 23, 2007 11:31 am
by John - Tracker Supp
Hi Peter,

Looks like the problem is because your function pView->PrintPdfFile(this);
and message loop are present in the same thread.

Please move the message loop or printing function to another thread - please let me know if this resolves the problem for you.

Re: Not getting "PDFXC3_StartDoc" from 64 Bit printer

Posted: Thu May 29, 2008 6:17 pm
by irik
Hi,
Have the some problem with using PDf-Xchange 3.0 driver in my C# application:
under 32 bit OS works fine but under 64 bit oS Vista wndproc does not catch the "ONDocStar" message
and does not create any pdf files.
What can be the problem?
Thanks,Irik Shafikov.

Re: Not getting "PDFXC3_StartDoc" from 64 Bit printer

Posted: Thu May 29, 2008 9:39 pm
by John - Tracker Supp
Please advise what build you are using and also the means used to communicate with the driver (ExtEscape, Messaging or ActiveX) - if the latter the only resolution may be to upgrade to Version 4.

Thanks

Re: Not getting "PDFXC3_StartDoc" from 64 Bit printer

Posted: Fri May 30, 2008 7:27 pm
by irik
Using the update release for v.3.0 and my app written in C# in VS2003.
It calles the print method of third party component written in VC++.
Wndproc is defined in C# application and trying to catch the registered "PDFXC3_StartDoc" message.
And the sample form the SDK works.

Re: Not getting "PDFXC3_StartDoc" from 64 Bit printer

Posted: Tue Jun 03, 2008 6:26 am
by Ivan - Tracker Software
All messages are sent by the driver with a timeout. If the message's recipient is busy (for example, it was into another message handler routine) this message will be not sent to this recipient.

HTH

Re: Not getting "PDFXC3_StartDoc" from 64 Bit printer

Posted: Mon Jun 09, 2008 2:41 pm
by irik
Ivan,
any way to fix that problem without upgrating to v.4?

Re: Not getting "PDFXC3_StartDoc" from 64 Bit printer

Posted: Wed Jul 02, 2008 9:25 am
by John - Tracker Supp
No - an upgrade is I am afraid the only resolution.