Problem with ::StartDoc

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
Tomcat
Posts: 2
Joined: Fri Jan 13 2006

Problem with ::StartDoc

Post by Tomcat »

Hi everyone!

I´m so happy i found this newsgroup, cause i hope you guys can help me :)

I´ve developed long time ago an Application which processes XML Files, and prints them with amyuni 2.10 to PDF Files. My Source for the printing to amyuni looks this:

Code: Select all

HDC hDC = CreateDC(_T("WINSPOOL"), m_szPDFPrinter, NULL, NULL);
if(NULL == hDC)
{
	m_strLastError.Format(_T("Device-Context von WINSPOOL mit dem PDF-Drucker '%s' ist nicht gültig."), m_szPDFPrinter);
	return false;
}

DOCINFO di;
memset(&di, 0, sizeof(di));
di.cbSize      = sizeof(DOCINFO);
di.lpszDocName = _T("Bericht");
di.lpszOutput  = m_strOutputPath + m_strOutputFile;

int nStartDoc = ::StartDoc(hDC, &di);
if(nStartDoc <= 0)
{
	m_strLastError.Format(_T("Fehler in ::StartDoc(hDC, &di)\nFehlercode: %d\nStartDoc Return: %d"), ::GetLastError(), nStartDoc);
	::EndDoc(hDC);
	return false;
}
This Application gets called, when a XML File arrives in a Folder. Then it processes this File, and prints it. But now, sometimes we get a failure in the call to StartDoc. StartDoc returns -1, and GetLastError returns then 3003.

After this Problem, there is a PDF File with 0kb and the amyuni printer has a print job. Both, the PDF File and the printjob, can´t be deleted. We have to restart our server and then we can delete them.

We can´t reproduce this Problem, it just happens about 1 time a day (application runs the hole day and makes about 500 prints). It´s a really confusing problem :? . Have you any idea? It would be great if someone of you have any idea which would help us!

Thanks in advance

Tom
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

The description you provide is not enough to know what could be going wrong, this type of issues needs in general to be debuged to check what is going wrong at the time when StartDoc is failing. But as the failure occurs randomly once per day it is difficult to trace it.

I will give you couple of suggestions:

1 - Please check that you are calling EnablePrinter() right before printing. If you are catching the driver events you can call EnablePrinter when catching the EnablePre() event.

2 - If you are in a multithreading environment please consider using the Locking mechanis of CDIntf. Lock functions available in CDIntf.

Hope this helps.
Tomcat
Posts: 2
Joined: Fri Jan 13 2006

Post by Tomcat »

Hello Joan!

Thanks for your answer.
Please check that you are calling EnablePrinter() right before printing. If you are catching the driver events you can call EnablePrinter when catching the EnablePre() event.
Can i call 'EnablePrinter' right before ::StartDoc? I don´t react on any driver Events.

It´s not a multithreading environment. How i´ve said, the application reads some data out of an XML File, prints it with List & Label (a reporting tool) to a .LL File. Then i want to print this file with the amyuni into a PDF File. But ::StartDoc gets a failure. I only call ::StartDoc one´s in the application, and sometimes it fails.

How you´ve said: debugging is quite difficult, cause the failure happens randomly.

What i don´t understand is that GetLastError returns 3003. MSDN say´s 3003 is "A StartDocPrinter call was not issued." But what this message mean?

Thanks anyway for your help!
Greetings from Tirol

--
Thomas
Post Reply