Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi all
we wanna Design the Activex that print array of string , but how to bypass array to the printcontroleventhandler as follow , because this is delegate:

C#
[ComVisible(true)]
        public string CreatePrint(Int16 iPrintCount,string[] arr)
        {
            try
            {
                this.Doc = new PrintDocument();
                this.Doc.PrintPage += new PrintPageEventHandler(this.PrtPage(arr));
                this.Doc.Print();
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }


but arr[] is wrong parameter.

What I have tried:

I test following code just when pass unique string is correct but when pass array is wrong.
Posted
Updated 17-Jun-16 2:10am
v2
Comments
Sergey Alexandrovich Kryukov 17-Jun-16 3:38am    
ActiveX used in browser is a big abuse. It won't work for most systems and browsers anyway; and this is very good. Besides... there is no such thing as "Java script"; Java is not a scripting language.

And using ActiveX on the server side would be totally pointless.

I have no idea why such trivial problem as printing some strings would need ActiveX. You should not control a printer from a Web application; this is way too intrusive.

—SA
bernova 17-Jun-16 8:19am    
Certainly you are a programmer, programmers is flexible in solutions that will be faces and solve it . just with small search you find the IETab that support activex in all browser , so the activex is not big abuse because the problem required use the activex
Richard Deeming 17-Jun-16 8:48am    
IETab doesn't support ActiveX in all browsers. Instead, it opens your site in an Internet Explorer window within the window of the browser the user wants to use.

The user has to be using Windows. The user has to install the IETab plugin. The user has to allow your site to download, install and script an ActiveX control not marked as "safe for scripting".

If your code is running on a private Intranet site, you might get away with that. If it's available on the public Internet, nobody is going to follow those steps to get your site to work.

1 solution

Please see my comment to the question.

Here is my suggestion: don't even play with the idea of doing anything like that. Instead, you have some civilized variants.

If data is emerged on the client side, use JavaScript to generate some content for printing; let the user print it the usual way.

If data is emerged on the server side, generate a Web page out of data using the usual ASP.NET techniques, including direct generation of HTTP response. You can navigate to the generated page if you want. Let the user print the page in the usual way.

Optionally, in both cases, you can create a button or other element to be clicked by the user. You can handle this click either on client side or server side (see above). Optionally, you can call window.print(), to print a window using JavaScript. However, this action seems redundant to me, because it will show same exact print dialog and do the usual printing; something the user could do without your help. You can do it if you think that your user is not a good browser user.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900