"Printer not activated, error code -20"

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
eheard
Posts: 4
Joined: Wed Sep 14 2005

"Printer not activated, error code -20"

Post by eheard »

Hey there,

I have seen some posts regarding this error message stating that it has to do with the activation code. Let me outline my case:

The app is written in ASP calling PowerBuilder 9.02 COM objects. The PB code is actually doing all of the work with Amyuni. The print-to-PDF code was all written against an older version of the converter (2.06), so there is a bit of mixing and matching - some calls are external functions/subroutines to the DLL and others use the ActiveX interface. All of this is running under IIS6 on Windows 2003 Server (I do not believe any SPs have been installed) with kernel mode driver printing enabled. I've trimmed down the code, but here are the various calls in the order they are called:

// Calls to the DLL
handle = printer.pdfDriverInit( printer.PRINTER_NAME )
rc = printer.setDefaultPrinter( handle )
rc = printer.setDefaultFileName( handle, _target )
rc = printer.setFileNameOptions( handle, printer.fileNO_PROMPT + printer.fileUSE_FILE_NAME )

// Working with the datastore
rs = _ds.modify( "datawindow.print.printerName='" + printer.PRINTER_NAME + "'" )
rs = _ds.modify( "datawindow.print.canUseDefaultPrinter='yes'" )
rc = _ds.print( false )

// Calls to the ActiveX interface
printer.open( _target )
printer.encrypt( "", "", printer.accessPRINT )
printer.save( _target )

The message comes up with _ds.print( ). The return codes from the DLL methods are setDefaultPrinter( ) = 1, setDefaultFileName( ) = 0, setFileNameOptions = 0. If I check getLastErrorMsg( ) for the methods that return zero, I get "The last action completed successfully". I threw this call in as well:


rc = printer.enablePrinter( handle, printer.licenseNAME, printer.licenseKEY )

It also returns zero and the same message. If I install the Amyuni driver using pdfdrv250.exe, I get the same message attempting to print a test page. I'd expect this as I believe we are licensed for development, but if that is the reason behind the message, why do I also received the message when making these calls programatically?

Thanks much,
-erich
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

For the demo page, it is normal not to be able to print a demo page from the Developer version, this is as you said licensed for developement.

Please add a call to EnablePrinter right after DriverInit() and right before the .Print command.

Hope this helps.
eheard
Posts: 4
Joined: Wed Sep 14 2005

Post by eheard »

Thanks for the response, Joan. I already tried to use the enablePrinter( ) method (I noted this at the bottom of my first post - sorry if I wasn't clear).

I was using the method within the DLL rather than the ActiveX interface. In the API document I have, it looks as if they are two different methods with one (the DLL) taking the internal Amyuni printer handle as an argument along with the licensee and activation code and the other (ActiveX) taking only the licensee and activation code.

The API guide also says that the return value from the DLL version of enablePrinter( ) will return true or false whereas the ActiveX version always returns false. I only bring this up because I want to make sure I'm not shooting myself in the foot by mishandling return codes. When I was calling enablePrinter( ) (DLL interface), I was getting a return value of zero (false) which if the API is correct would incline me to believe the call failed. If, however, the ActiveX documentation is correct, then I should get false irregardless -see my dilemma;)

I'll try adding the call to enablePrinter( ) in again, perhaps I had the licensee or activation code entered incorrectly.

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

Post by Joan »

Hello,

In the documentation it is mentioned that in the case of the DLL, EnablePrinter returns False if the printer handle is invalid and true otherwise.
If using the ActiveX, EnablePrinter() returns false in all cases.

You are right that in the DLL EnablePrinter takes 3 parameters, the printer handle and the licensee and activation code where as in the ActiveX EnablePrinter takes only 2 paramters the Licensee name and the activation code, this is how the function interface is designed.

In your code you are calling:
rs = _ds.modify( "datawindow.print.canUseDefaultPrinter='yes'" )
rc = _ds.print( false )

I suggest that you call:
rs = _ds.modify( "datawindow.print.canUseDefaultPrinter='yes'" )
rc = printer.EnablePrinter(LicenseTo, ActivationCode)
rc = _ds.print( false )


If you are still getting the 'Printer not activatated' message, please send us the licensee name and activation code you are using to check them.

Thanks.
eheard
Posts: 4
Joined: Wed Sep 14 2005

Post by eheard »

Thanks again, Joan. It looks like I will need to get our license code to you. I tried placing enablePrinter( ) in the position you noted. I tried both the DLL and ActiveX versions and both times I received the same "Printer not activated" message.

Also, I am still getting what appear to be failure codes from the setDefaultFileName( ) and setFileNameOptions( ) calls. That is, they are both returning zero (which the API says is a failure) however getLastMsg( ) returns "The operation completed successfully. Let me know how to get the information to you.

Erich
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

Below is a code snippet which prints the datawindow to the PDF Converter. Can you verify if you are to run this?


//******************************Function Declarations****************************
Function Long DriverInit(string sPrinter) Library "cdintf250.dll"
Function Long SetDefaultDirectory(Long PDF,string sDirnm) Library "cdintf250.dll"
Function Long SetDefaultFileName(Long PDF, string sFile) Library "cdintf250.dll"
Function Long SetFileNameOptions(Long PDF, Long lOptions) Library "cdintf250.dll"
Function Long DriverEnd(Long PDF) Library "cdintf250.dll"
Function Long PDFDriverInit (String sPrinter) LIBRARY "cdintf250.dll"

//New functions for version 2.50
//this programmatically enable printer
Function long enableprinter( long PDF, string szcompany, string szcode)Library "cdintf250.dll"

//*******************************Code***************************************
//Declare variables
Constant string PrinterName = "Amyuni PDF Converter"
Constant Integer NoPrompt = 1
Constant Integer UseFileName = 2

//Varibles
string PrinterName

//Using dll variables
Constant string OutputFileDll = 'c:\temp\powerbuilder.pdf'
Constant string DefaultDir = 'c:\temp'
Long PDFPrinter


//Using the dll interface
//Initialize PDF printer

PDFPrinter = DriverInit(PrinterName)



SetDefaultDirectory(PDFPrinter,DefaultDir)
SetDefaultFileName(PDFPrinter,OutputFileDll)

SetFileNameOptions(PDFPrinter,3) //NoPrompt + UseFileName


//enable printer accept string values
//this needs to been done each time
//datawindow is printed
enableprinter(PrinterName ,"Evaluation Version Pro Developer","07EFCDAB01000100A66226099F4E97C15FEA66AD9FE171BD7BF1794731421BA6094A98714DBEC67F2FC876C904298D0FC77BF1F0BBCFBCC46A9CCB35AED81EBDC5968BB69D966304B551099779EBCE055C1E91E3D3D4FD2709D00B19EA3777A099E8226B399D1BBCC94982D02342BCF355")

dw_page1.Object.Datawindow.Printer = PrinterName
w_app_powerbuilder_rpt.dw_page1.Print()


SetFileNameOptions(PDFPrinter,0) //clear

DriverEnd(PDFPrinter)

Hope this helps?
eheard
Posts: 4
Joined: Wed Sep 14 2005

Post by eheard »

Thanks Jose, sorry to take so long to get back - I am on the road curently. I will try the code you posted as soon as I can. If for some reason that doesn't work, I will send you and Joan the user name and code I am using.

Thanks much,
Erich
Post Reply