Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: DHTML
Expertise: Beginner
Jul 26, 1999

Printing a Barcode (GIF) From Netscape 4.05+

Question:

I have a barcode saved as a GIF that is truncated each time it is printed from Netscape. It prints fine in Internet Explorer and Netscape 4.04 but does not work in subsequent versions of Netscape. The GIF displays properly but is altered when previewed or printed. I have looked at your comments related to printing DHTML and felt that my issue is similar. I was unsure how to print the window created by your JavaScript in this response. I was able to generate the PrintWindow but didn't know what to do next. I have simple HTML and GIF files to demonstrate this problem.

Answer:

Barcode output from a file image is always a little problematic, since in addition to possible truncation issues you also have the possibility that the GIF pixel approximates won't translate exactly to a specified width on a printed page. Some things that may help:

First, always make sure that you specify exact dimensions with the GIF. If you don't, then the printing engine may alter the aspect ratio slightly to get an image on the page. Second, try to put the GIF on the left-hand side of the page—with the GIF on the right, compression of the image is more likely. The purpose of the print window is simply to get your output in a format that doesn't have any code in it that may change the screen image but not the internal representation. Also, keep in mind that the typical screen resolution is 72, 84, or 96 pixels per inch, respectively, depending upon the resolution of the monitor. The printer, on the other hand, will typically have resolutions of 300, 600, 1200, or 2400, which means that when one gets mapped to the other, graphics in particular may suffer, since they have to be rescaled to 300/72 or some similar multiple.

One possibility that you may want to think about (I don't know whether this will work or not) is to render the initial GIF to the target resolution of the printer. For example, if you're going to a 1200 dpi printer as a one inch wide image, then make your initial GIF image 600 dots per inch (1200 is probably overkill), and set the width and height tags to some division of 2 of that (i.e., width=300, width=150, and so on). The screen representation will be scaled to something reasonable for display, but when the printer polls the graphic it'll apply a detail preserving transform (from the multiples of 2) to insure that it retains proper proportions. Note this is only a guess, but I think it should work.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap