Error 482 when trying to print and need advice

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
mjanum
Posts: 6
Joined: Mon Jul 19 2004

Error 482 when trying to print and need advice

Post by mjanum » Mon Jul 19 2004

Hi

Current system: Win XP, VB6, Document convertor suite 2.10i

I have created a standard .exe vb project and trying to execute the sample code from the documentation, see below, but i receive an error 482, from other posts i can see it is probably related to the enable printer call, but i cant seem to see what i am missing.

Also need a bit of advice on my approach on our project, i want to be able to capture when a user in a program prints to the document convertor printer, then take the print out put and do some postprocessing. my approach is:

1) Install development edition document convertor with company name as printername (permanent printer)
2) Install postprocess application in startup folder, when user logs in the application starts up the monitoring of events from the printer
3) when user prints to the company name printer the event is raised and processing can happen

is this the best approach? In the sample code the setsystemdefaultprinter is set, can i leave this out, so i dont change the default printer for the user but still be able to capture the printer events?

Thank you, current code is provided below.

-- begin code --
Const LicenseName = "Converter Evaluation Developer"
Const LicenseKey = "07EFCDAB010001005508708341FA27688B4677FD9F0949D06B3E571BA69FAED5D5C39249776339468C6EA491C4EE6A623009DBB774A2FE1156D8FB96104CA5A98A09553A526E0BD5D52E18005B567947D12396CEE8582B247059535C597904B32F14CD1245B1"
Const PrinterName = "Document Converter"

Private Sub CDIntfEx1_EnabledPre()
CDIntfEx1.EnablePrinter LicenseName, LicenseKey
MsgBox "Enabledpre"
End Sub

Private Sub CDIntfEx1_EndDocPost(ByVal JobID As Long, ByVal hDC As Long)
MsgBox "EndDocPost"
End Sub

Private Sub CDIntfEx1_StartPage(ByVal JobID As Long, ByVal hDC As Long)
MsgBox "StartPage"
End Sub

Private Sub Command1_Click()
CDIntfEx1.FileNameOptions = Hex(1) + Hex(2) + Hex(20) ' Noprompt, usefilename, broadcast
CDIntfEx1.DefaultFileName = "c:\temp1.pdf"
Printer.CurrentX = 200
Printer.CurrentY = 400
Printer.FontName = "Arial"
Printer.Print "Hi there" ' error 482 occurs here
Printer.EndDoc
End Sub

Private Sub Form_Load()
CDIntfEx1.PDFDriverInit (PrinterName)
CDIntfEx1.EnablePrinter LicenseName, LicenseKey
CDIntfEx1.SetDefaultPrinter
CDIntfEx1.CaptureEvents True
End Sub

Private Sub Form_Unload(Cancel As Integer)
CDIntfEx1.CaptureEvents False
CDIntfEx1.RestoreDefaultPrinter
CDIntfEx1.DriverEnd
Set CDIntfEx1 = Nothing
End Sub

-- end code --

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

Post by Joan » Thu Jul 22 2004

Hello,

I noticed in your code that you are not calling EnablePrinter before printing, this is causing the error, you need to call EnablePrinter after calling PDFDriverInit and right before printing.

In your code it seems you are installing the printer when launching your application and your remove it when clausing your application, you may install the printer and keep it on the system if you wish so users who don't have administrative rights under XP or 2000 will not face problems running your code.

I didn't get your question about setting the printer as default.

Hope this helps.

Joanna

mjanum
Posts: 6
Joined: Mon Jul 19 2004

Post by mjanum » Thu Jul 22 2004

I Thought i did it in the following section:

Private Sub Form_Load()
CDIntfEx1.PDFDriverInit (PrinterName)
CDIntfEx1.EnablePrinter LicenseName, LicenseKey

But you want it to be inserted right before i call

Printer.Print "Hello" ?
(if so how can o code a utility that monitors the printer for printed documents, and raises i.e. enddoc events?)

Regarding the printer as default, then this is the scenario:

My plan is to have the following happen during an install

1) my install program install the printer permanently
2) my install program also installs a small utility in the startup folder
3) the small utility will start monitoring the printer for messages, if the user prints to the printer (from any windows program) I want the utility to be able to postproces the document the user has printed to the printer

Is it the right approach to install the printer permanently and then have a utility monitor it for messages, or is there a better approach (to postprocess a document printed from any windows program to the printer)?

And if the utility is monitoring, then all the examples, shows that the printer is set to the users default printer and then monitoring of messages is started, but instead i want the user to be able to maintain their current default printer and only if the user selects my installed printer, then i want to do the postprocessing.

I appreciate your help. Thanks.

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

Post by Joan » Mon Jul 26 2004

Hello,

Yes, you need to call EnablePrinter right before:
Printer.Print "Hello"

You can catch the events generated by the driver and when you catch the EnablePre even you can call EnablePrinter.
For more information about catching events please check our Developers' manual "Common Driver Interface 210.pdf".

You can install the printer permanently on the system and have a a tool to monitor the events generated by the driver or you can monitor these events from inside your application because the Developer version of the driver should be used only from inside your application.

Finally, you need to set the PDF Printer as default only if you don't have a way to print from inside your application to a specific printer on the system without being a default printer.

Hope this helps.

mjanum
Posts: 6
Joined: Mon Jul 19 2004

Post by mjanum » Mon Jul 26 2004

Hi

I tried to insert the following line, but i still get the error, I do see my msgbox from the enabled pre event

Printer.FontName = "Arial"
CDIntfEx1.EnablePrinter LicenseName, LicenseKey
Printer.Print "Hi there" ' error 482 still occurs here
Printer.EndDoc

not sure how i can get around this :-( any help is appreciated

mjanum
Posts: 6
Joined: Mon Jul 19 2004

Post by mjanum » Mon Jul 26 2004

This is a bit weird.

I created a .exe file from the above code and copied it to another machine where i did a clean install of the document converter. Here it worked for the first time i ran it. Then i installed VB6 studio and ran the code with the debugger and now it gives me the same error again, i am a bit stuck, any help would be appreciated. Do any license file need to be copied to a certain directory when doing vb6 debugging?

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

Post by Joan » Wed Jul 28 2004

Hello,

Please try the following:

Please install the printer on the system using Install.exe
Replace PDFDriverInit in your code by DriverInit.
Try to run your application.

Hope this helps.

jc
Posts: 1
Joined: Thu Jan 27 2005

Post by jc » Thu Jan 27 2005

Hi Joan,
We are trying to implement the document converter suite ( 2.10i -8 ), developer edition.
Can you please confirm whether we can use the converter suite as follows:

We want our end users to be able to print from any windows application and have our application catch the print events and pass the print data onto Excel for further editing, before the user saves the file. Is this possible with the Developer version of the Document Converter Suite? From what I have read in this forum, it seems this is not possible.

Is there any way to accomplish what we need with your products?

Thanks

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

Post by Joan » Fri Jan 28 2005

Hello,

No, this is not possible with a Developer license.

You need a special license agreement to do that. For more information please contact sales@amyuni.com

Have a nice weekend.

Post Reply