Custom printing from Firefox (Windows Only) - firefox

I have created a .NET Windows Forms component that runs within IE via an <object /> tag and allows me to print to a thermal label printer directly from a web page using the Windows API's to bypass the driver and send raw commands.
This all works, but my customer is now asking for similar functionality from Firefox!
What I need to do is to be able to pass the name of the printer that I want to use (this is configured within the web application) and then pass a string that is to be sent directly to the printer without being intercepted by the driver translation. I can acheive all of this by gaining access to the following Win32 API's (as I currently do from my .NET component)...
OpenPrinter
StartDocPrinter
StartPagePrinter
WritePrinter
EndPagePrinter
EndDocPrinter
ClosePrinter
I have looked at the options, and as far as I can see the only path available is XPCOM. Can anybody advise me as to whether I have reached the right conclusion before I start down this path as it appears that there is a great deal of work involved in creating an XPCOM extension and I would hate to spend a lot of time on it only to find out that either ...
There is an easier way
XPCOM will not do what I want!
Thanks in advance.
BTW: I am not looking to enable the existing .NET component to work in Firefox, I believe that I will have to start from scratch and create a Firefox extension that can be used instead.

Related

UIAutomation event for when PDF downloaded in Internet Explorer

I am trying to handle an event for when a PDF has downloaded and been fully displayed in Internet Explorer.
Which UIAutomation event will handle this?
If you are referring to the UIAutomation object in the .NET Framework, it supports managed code. Internet Explorer is written in C++ as unmanaged code. Some folks have managed to write extensions using managed code, in spite of clear advice to the contrary, however, I've not heard of anyone successfully controlling IE using managed code.
Earlier versions of IE could be automated using COM interfaces or VBA objects, however, these features have been increasing deprecated over the years.
In addition, few of those interfaces supported extensions. (PDF is not a natively supported file type for Internet Explorer, so automation would depend on the surfaces exposed by the application registered to handle PDF mime types for the individual user.)
Since Edge is now the official browser, it's unlikely that IE will be updated to support managed code extensions. Note that Edge does not currently support extensions and little information is available describing when, or if, that will change. (There have been vague promises in the past, but little additional information.)
If you're trying to accomplish a specific effect, consider posting a more specific question, one showing:
The code that you're trying to use,
The effect you're trying to achieve, and
The behavior you're seeing instead.
Hope this helps...
-- Lance

Does Windows, Outlook, or Exchange have an API for reading iCal format?

I'm trying to add iCal import support to my existing scheduling application which needs to support Windows XP, Vista, and 7. Writing iCal format is easy, but reading it is another story, mostly trying to convert times to local times with the complex TIMEZONE/TZID/RRULE syntax. Ideally Windows would have a native API for this, but I haven't found one.
I know Outlook 2007+ has an OpenSharedItem function that would work. I don't want to require users to have Outlook installed though, since my application "competes" with Outlook. I thought about writing a web service that would use Outlook on my web server to do this, but I know using Outlook OLE/COM objects from a service has issues, so that probably isn't an option either. I do own about 300 Exchange Server licenses, are there any APIs with Exchange that would maybe work better? I do notice when I email iCal files from GoToMeeting.com they say they were created with "Microsoft CDO for Microsoft Exchange", so I have a feeling they are doing something like this to avoid writing the format themselves.
My application is written in C++ using mostly native Win32 API, but I don't mind creating a .NET DLL for this, or even requiring users to have Internet access so I can post the file to my web server and have it return a converted format my app can use easily. My web server runs on Windows though, so anything Unix-based might be dificult. Other than that, I'm pretty open to options.
Update: I did find CDOEX but as I've never used it before, can anyone tell me where to start and if it can in fact do what I need? I don't really see much about iCal in the docs, and I'd need to install Exchange on my dev PC (not crazy about that) to start playing around with this API.
You can try to use Redemption (I am its author) - it allows to explicitly import iCal files using RDOAppointmentItem.Import(..., olICal).

Best method for a webpage to access a mac's peripherals?

I'm building a web-based application that can use ActiveX Controls to print to a Thermal Label Printer (specific to shipping labels) in Windows environments, but I am racking my brain to figure out what the best method would be for OSX. Obviously ActiveX doesn't work on macs...
Any ideas about where to start looking? A flash movie? A firefox add-on? My fingers are tired of googling.
There's no way a vanilla web language will allow you to control peripherals from a webpage under Mac OS.
If you really really need to call that from a webpage and can't afford to make a real application, your best go under Safari would be to build a plugin to use Objective-C from Javascript, and do the heavy-duty work from within your plugin. A similar solution probably exists in Firefox.
Also, as I understand it, your program runs on the client with the printer attached. You could write a server-side script and install it on the Macs, and then have your webpage drive it to do the printing.
My first choice to solve this problem quickly would be to use an enterprise label print server like Loftware or Bartender. But, like you said, they are expensive and you are planning on reselling your product.
My second choice would be to scrap the activex control and build a simple print server. There is no standard control language in the label printer world but if you are going to standardize on a certain class of Zebra printer you would only need to implement one driver at first. I have only ever done this for Datamax printers but I'm sure the process for Zebra printers is similar.
The server takes your label data as input (pallet ID, ship to address, etc), inserts that data into a template (painstakingly crafted in the text based printer control language) and then this label file is sent to the appropriate printer.
My third choice would be the browser based solution you are looking for. IT departments hate that stuff.
You can create an NPAPI plug-in, which will work in Safari, Firefox and other Mac web browsers. You'll need to have the user install the plug-in on their system before it can be used, there's no way to install it automatically.
Can't you just use the JavaScript printing API?

Using the browser for desktop UI

How can I use the browser as a UI for a desktop app? The ways I have come up with so far are...
Use all HTML/Javascript. Problem: Can't access filesystem or just about anything else.
Run a local webserver while the application is in use. Problem: How do I kill it when the user is done? My users are not technical enough to Ctrl+C.
Embed a browser component in a regular GUI. Problem: Embedded browser components tend to be glitchy at best. The support for Javascript/CSS is never as good as it is in a real browser.
...?
The ideal solution would work with any technology. I know there are options like writing Firefox extensions, but I want to have complete freedom in the backend technology and browser independence.
Please note that if you choose to run a local webserver, you're creating a security risk.
Any webpage running on the same machine that knows about your app can send requests to your server using Javascript, and you have no simple and reliable way of knowing what the request came from. (Don't trust the referer header)
Google Desktop, which uses a similar approach, has had several real-world vulnerabilities that allow any webpage to read any file on disk.
There are several ways to protect against this; I would recommend requiring each request to have a auth key which is randomly generated per-machine (and expires at some point), which you could put in the source for the actual pages. XHR protection would prevent malicious websites from reading the auth key, rendering them powerless.
If you are looking for a python Web Server with a Kill link, you could always check CherryPy.
import webbrowser
import cherrypy
import threading
class MyApp:
""" Sample request handler class. """
#cherrypy.expose
def index(self):
return """<html><head><title>An example application</title></head>
<body>
<h1>This is my sample application</h1>
Put the content here...
<hr>
Quit
</body></html>"""
#cherrypy.expose
def exit(self):
raise SystemExit(0)
class MyBGThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start()
def run(self):
cherrypy.tree.mount(MyApp())
cherrypy.quickstart()
myThread = MyBGThread()
webbrowser.open("http://127.0.0.1:8080")
This code is based on the sample from the SingleClickAndRun on the cherrypy website:
http://tools.cherrypy.org/wiki/SingleClickAndRun
Note than in a normal WebApp you would probably use a templating engine and load templates from methods like main.
Something that would be nice would be to embbed a browser control in a gui window and close the server when the app exits.
For the security, you could possibly add an authentication scheme. There are a few that are supported by cherrypy, but you possibly could implement your own too, using tool modules.
I am looking to do the exact same thing (desktop app that uses an up to date HTML5 / CSS3 browser as the desktop app's GUI), only with Ruby (various reasons why I decided to work with Ruby). Its amazing the number of cross platform libraries people have come up with. But yet, few to no one, has done any work on trying to get a web browser to be a desktop app UI. Cross platform issue... well I won't say solved, but I will say several steps in the right direction taken.
To me this would be perfect with the new HTML5 / CSS3 standards coming out. I know it can be done with a web server running locally.
Another way might be like how the guys from “280 North” are doing what they do. They developed Objective-J (an extension of regular JavaScript that mimics how Objective-C extends regular C) and Cappuccino (the Objective-J equivalent of Objective-C’s Cocoa frame work on the MAC). They also developed “Atlas” which is 280 North’s version of Apple’s “Interface Builder” from Xcode, for their Objective-J and Cappuccino frameworks to build Internet Applications. Atlas is actually a Cappuccino web app running on your desktop as a desktop app. In this case they use the Narwhal… a cross platform, general purpose, JavaScript platform for developing JS apps outside of the browser (basically a specialized web server).
If any one can come up with an idea to make “Browser, direct connect to Desktop App” work without the need of a web server co-existing and still get to manipulate the local FS, I to would be very interested… Hmmm... Now that I think about it, I wonder if the new Google Chrome project “Native Client” can be used to do that. NaCL is much like Active X except you are not limited to a windows platform (but will be limited to the Google Chrome browser, at least for now). Only there is added security via Sandboxing, but you can manipulate the local FS… The more I think about it, the more I am beginning to suspect that it can be done.
Any thoughts?
In Windows, you could embed the IE ActiveX control, which uses the same rendering engine as IE. (That's a plus and a minus) You can set the ScriptObject property in your host code and access it in Javascript as window.external to do things that Javascript cannot do.
If you run a local webserver, you could have an exit link in the app that kills the websever.
You did not mention the OS you will need to target. But you might be able to create a program statared web server, then launced the default browser. Wait until the browser is terminated by the user and then shut down the web server.
So for example on windows you can use CreateProcess() to spawn the process
then MsgWaitForMultipleObjects() to wait until it is finished executing.
HTML Applications (HTA, for short) have been around for a while. You can read all about them here. They are basically HTML and Javascript with some extra options to create a window and with access to the local file system. They seem to be exactly what you want. It is Microsoft technology, so this will only work with IE on Windows systems. I've successfully used this as a front-end for a CD-ROM which was used to distribute software to first year students
Another option would be to use Adobe Air. I'm not all that familiar with the technology, but it seems to provide a framework to deploy web pages as desktop applications. I can't post a second link as a guest, but just google it and you'll find it soon enough.
Today, in 2023, you can simply use any installed web browser as GUI using the WebUI library.

Is it feasible to write a Firefox plugin to make use of ActiveX control on Windows?

I use an ActiveX control called TAPIEx enabling TAPI phone system integration using MS Access 2000 (+Visual Basic). I want to turn this Access database into a web app with the clients running Firefox (all on internal network).
Since Firefox doesnt support ActiveX is it feasible for me to write a Firefox plugin that in turn utilizes the ActiveX control?
With regard to how plugins work - Would I be able to call 'functions' of the plugin from page script (eg dial call specifying phone number, check if calls in process)? Would adding these functions to the Firefox right click menu 'globally' inside Firefox be easier?
Hope you guys can help. Note I'm not a fulltime programmer; I just need to know how steep the learning curve will be or even if my idea is possible!
Ive now found a project to allow using activex controls in firefox that seems to be quite up to date at:
http://code.google.com/p/ff-activex-host/
Theoretically, yes you could write a Firefox plugin with C++ that talked to the ActiveX component via COM. But the learning curve for both COM and C++ FF plugins are both horribly steep. I wouldn't recommend it.
As Kalmi says, just use IE.

Resources