Call to BatchConvert hangs

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
charux
Posts: 3
Joined: Tue Jun 01 2004

Call to BatchConvert hangs

Post by charux »

I'm evaluating PDF Converter Version 2.1 developer. [PDF Converter Professional works great]. I can't get it to convert a .doc file:

I installed the dll by running Setup.exe, adding a reference to cdintf.dll in my .NET project and then calling it per examples posted in this forum:

Code: Select all

Dim printerName As String = "Amyuni PDF Converter"
Dim license As String = "07EF... "
Dim cdi As New CDIntfEx.CDIntfEx()

cdi.PDFDriverInit(printerName)
cdi.EnablePrinter(printerName, license)
cdi.SetDefaultPrinter() 
cdi.DefaultDirectory = "C:\amyuni" 
cdi.FileNameOptionsEx = &H1& 
cdi.EnablePrinter(printerName, license)
cdi.BatchConvert("C:\MyFile.doc")
cdi.FileNameOptions = 0
After the call to PDFDriverInit(), I can see a new printer installed in the printers folder.

After BatchConvert(), MSWord is opened, with the file loaded. Word then pops up the error message:
Windows cannot print due to a problem with the current printer setup. Try one or more of the following:
*Check the printer by printing a test page from Windows.
*make sure the printer is turned on and online.
*Reinstall the printer driver.
When I click OK it adds:
Runtime Error '1046'
When I kill the Word app, my program remains hung [it times out and BatchConvert() returns if I leave it running long enough].

I have a feeling I'm missing something very basic.
I get the same results if I use the AxCDIntfEx control.

Any help appreciated.

Thanks.

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

Post by Joan »

Hello,

Please call EnablePrinter right after PDFDriverInit and right before your call to BatchConvert.

Also please replace:
cdi.DefaultDirectory = "C:\amyuni"
By
cdi.DefaultDirectory = "C:\amyuni\"

And check that the folder amyuni already exists on C:\ , otherwise no pdf file will be generated.

Hope this helps.
charux
Posts: 3
Joined: Tue Jun 01 2004

Post by charux »

Joan,
Thanks for the suggestions.
I'm already calling EnablePrinter right after PDFDriverInit and just before BatchConvert, and I added a backslash at the end of the path for DefaultDirectory. I'm still getting the same error message.

I suspect my calls to EnablePrinter are failing. I've retrieved the return values of EnablePrinter. After

Code: Select all

cdi.PDFDriverInit(printerName)
retval = cdi.EnablePrinter(printerName, license)
retval is 0 [= false, I guess]. Based on the C++ documentation, "The return value is False if the printer handle is invalid, True otherwise" I suppose Enable printer failed.

The subsequent call to SetDefaultPrinter returns -1 [undocumented], and the call to EnablePrinter before BatchConvert returns 0. I'm using the licence string from LicCode in the Install.ini file.

What am I doing wrong? Any suggestions would be appreciated.
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

You will need to send the license code and activation code to support@amyuni.com to check it if it is valid or not.

Thanks.
charux
Posts: 3
Joined: Tue Jun 01 2004

solved!

Post by charux »

Many thanks to Jose at Amyuni support. I was calling EnablePrinter() with the wrong arguments. Here's a VB.NET example that works:

Code: Select all

        Const strLicensTo = "Evaluation Version Developer"
        Const printerName As String = "Amyuni Developer Converter"
        Const strActivationCode = "07E ... " 'long string omitted for readability
        Const NoPrompt As Int32 = &H1&       ' do not prompt for file name
        Const UseFileName As Int32 = &H2&    ' use file name set by SetDefaultFileName 

        Dim cdi As New CDIntfEx.CDIntfEx()
        cdi.PDFDriverInit(printerName)
        cdi.DefaultFileName = "C:\amyuni\out.pdf" 
        cdi.FileNameOptionsEx = NoPrompt + UseFileName
        cdi.SetDefaultPrinter()             'make pdf printer default
        'uncomment next statement if you're not setting DefaultFileName and UseFileName-
        ' the output pdf file name defaults to <input filename>.pdf in the DefaultDirectory you set here:
        'cdi.DefaultDirectory = "C:\amyuni\"
        cdi.EnablePrinter(strLicensTo, strActivationCode)
        cdi.BatchConvert("C:\inputMSWord.doc")
        cdi.RestoreDefaultPrinter()
        cdi.FileNameOptions = 0
        cdi.DriverEnd()
Post Reply