PDA

Click to See Complete Forum and Search --> : Barcode Font problem


JemimaChadwick
Sep 8th, 2004, 04:49 AM
Hi,
I have a requirement to display and print barcodes. I am using the Code39-digits font to display the number in barcode format. I want my web application to detect if the font is installed in the client machine and prompt the user to download the font if not.

Any suggestions on how this can be done?
Thanks
Jemima.

Acidic
Sep 8th, 2004, 04:59 AM
To read a clients PC is very iffy. You should probably use Active X for this, but you will have major problems. Firstly Active X can only be used by IE: big ****ter. Secondly people will have to lower their security settings, that's more than most people will do.

Maybe Java could do thie trick, in which case that would be an ideal solution. The best thing might be for them to check it themselves. Write out the alphabet in that font, and just below have an image of what it should look like in that font. They can then see if those match and if they don't then they have to download the font.

JemimaChadwick
Sep 8th, 2004, 05:11 AM
Thanks for the quick response Acidic!

The site is for within the intranet and we also have the liberty of assuming the browser to be IE (We're blessed!)

I can't expect the security settings to be reduced though. I am looking at some Javascript code that will either help me loop thru the available fonts on the client machine or that will tell me if the barcode got written on the browser.. maybe some sort of a work around...

We have an option with the WEFT, worst case. If that ain't accepted then I'm gonna propose jus this:
"The best thing might be for them to check it themselves. Write out the alphabet in that font, and just below have an image of what it should look like in that font. They can then see if those match and if they don't then they have to download the font."

Thanks again!
Jemima.

Acidic
Sep 8th, 2004, 05:24 AM
JavaScript cannot read files on the PC. This is a good thing as otherwise there would be security concerns on every site.

Hmm... Since you are using only IE there might be some IE only JavaScript functions that can actually do this though. I've never used these as they are IE only but I'm having a google as i write.

Acidic
Sep 8th, 2004, 05:34 AM
OK. I've found something that you can maybe use. Read this page:
execCommand() (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/execCommand.asp)
and use this method for that function:
SaveAs (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/execCommand.asp)

JemimaChadwick
Sep 8th, 2004, 05:55 AM
No I didn't quite understand. What command should I give? I tried "FontName" but how will I know if the font existed?

Jemima.

Acidic
Sep 8th, 2004, 06:01 AM
Oh sorry. I got muddled up with what I was doing half way through fdoing it and came out with totally irrevelent stuff.

They do have an Open method, but they don't support it. So I guess you can't use JavaScript at all for this then.

If it's on an intranet, then I suppose it's all within one company. Why don't you install the font on all the machines?

JemimaChadwick
Sep 8th, 2004, 06:40 AM
Installing the fonts on the destination machines was the initial idea. But going forward we had to think of an alternative when a new box got added.

I am still beating around with the hopes of finding a Font object that would pull the fonts on a machine or be able to trap from the browser if the barcode got displayed.

I just remembered that my page will be a print preview where the users can print the invoice as is.. so I can't have the help message on the same page but I could redirect them to a startup page at logon and let them decide if they need to install the font. If they could view the barcode I could probably save this into a cookie and proceed. This or WEFT? There's just 2 options for now.

Thanks for your time Acidic.
Jemima.

Jop
Sep 8th, 2004, 07:06 AM
I suggest using php (http://www.php.net) and then this barcode library (http://pear.php.net/package/Image_Barcode/docs/0.5/apidoc/Image_Barcode-0.5/Image_Barcode.html) to turn your barcode into an image and display that instead.

JemimaChadwick
Sep 8th, 2004, 11:10 PM
The site is in ASP.NET and C#. Can't use PHP - its not within our standards and I don't know PHP too.

Thanks anyways, Jop! We had thought of the option to convert the barcode to an image and stream it into the client but performance constraints in streaming in barcodes for records as many as 200 won't be a good idea.

We're still trying. Somehow I have a feel some Javascript (not too complex or straight forward) should do the trick...

Thanks
Jemima.

Acidic
Sep 9th, 2004, 03:23 AM
Maybe you should consider installing PHP. What Jop said is a very good idea and if it cannot be done with ASP, then maybe you should try out PHP. I'm sure that you can learn enough for this, or else someone might write the code for you. I would write it myself, but I've never used those text to image functions.

JemimaChadwick
Sep 9th, 2004, 03:33 AM
That's very sweet of you to offer, Acidic; but we do have code in C# (downloaded from the net) that would convert text to image and all.. and like I said the issue was in streaming the image back to the client for around 200 invoices per request. That hits the performance of the web server. Hmm.. Still its one of the design options we've kept open.

As for PHP, I don't have a say. Our client's coding standards do not give in to use PHP.

Thanks
Jemima.

Jop
Sep 9th, 2004, 05:29 AM
Actually i'm pretty confident that it can be done in ASP.NEt even though I haven't used it in a while. If you can convert text to images, you can probably use ASP to generate the barcode from a font you install on the server.

It's not gonna be a big performance hit either since the images are going to be only a few k if you use a gif, plus that you can cache the barcodes so that they don;t have to be regenerated every time.

I"m sorry that I can't provide you with any examples, but this manner described above is the general idea of how I would do it.

Good luck with it!

JemimaChadwick
Sep 9th, 2004, 05:40 AM
It would have been a clean sweep choice if we could have cached the images. But the barcode images can't be cached as they'll be different order numbers each time.

Also we're having this ASP.NET code (in C# syntax) that will convert the text to an image on the server but rather than creating a GIF (or any other image format) file, we'll simply stream the image and binaryWrite it to the web page. That way the overhead traffic of streaming in each image was an issue.

I also found that the font that is installed on the client machines is not supported by WEFT and so we can't embed this font as well. So now that we're left with not too many options to choose from, we'll just have to submit these 2 ways and wait n watch.

Thanks all for your suggestions!
Jemima.