从网页打印条码code标签 [英] Printing barcode labels from a web page

查看:126
本文介绍了从网页打印条码code标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个ASP.Net Web应用程序,必须在标准艾利风格的标签纸打印动态创建的标签(一个特定的大小,所以只有一个总体布局)。标签具有可变的行数(3-6),并可以包含文本或图形酒吧code图像的任意行。

I am working on an ASP.Net web application that must print dynamically created labels on standard Avery-style label sheets (one particular size, so only one overall layout). The labels have a variable number of lines (3-6) and may contain either lines of text or a graphic barcode image.

我们的首次下调,那我继承,使用等宽字体减少格式问题,但没有提供足够的文本是否吻合标签和客户的不满。基本上,它是格式的文本。

Our first cut, that I inherited, used monospaced fonts to reduce the formatting issues, but that did not allow enough text to the fit on the labels and the customer was dissatisfied. Basically it was formatted text.

我的下一个版本中使用的表,的DIV,CSS和JavaScript代码的计算使用比例字体的标签格式。它仍然需要进行一些调整(用户必须正确设置它们的打印边距和关闭打印页眉和页脚),但它似乎工作。

My next version used TABLEs, DIVs, CSS, and a bit of JavaScript calculations to format the labels using proportional fonts. It still required a bit of tweaking (the user had to set their print margins correctly and turn off the print headers and footers), but it seemed to work.

不过,似乎有对打印机有什么不同呈现文本一些变化(WYS不WYG),所以尽管我们测试使用至少两种不同的打印机(喷墨和激光打印机)不同的浏览器,一些用户的标签,不用排队。轻微余量的变化可以通过调整在页面设置对话框边距进行调整,但较硬的问题是,标签间间隔可以由一英寸的一小部分被关闭,因此,如果第一个标签是pretty井中心,由页面的结尾标签的文本和图像的抓取断标签的顶部或底部。

However, it seems that there are some variations on how different printers render the text (WYS ain't WYG), so even though we tested on different browsers using at least two different printers (an inkjet and a laser printer), some user's labels don't line up. Slight margin variations can be adjusted by adjusting the margins on the page setup dialog, but the harder problem is that the inter-label spacing can be off by a tiny fraction of an inch, so that if the first label is pretty well centered, by the end of the page the label text and images have crawled off the top or bottom of the labels.

我们将要切换到生成的Word,Excel或PDF输出,会采取相当多的开发时间,并尽可能增加在印刷过程中额外的步骤的地步。

We are about to the point of switching to generating Word, Excel, or PDF output which is going to take quite a bit of development time and possible add extra steps in the printing process.

因此​​,没有人对如何做一个HTML / CSS布局,将precisely渲染不同类型的打印机有什么建议?我真的不关心,如果该行/断字是有点不同,但我需要能够以predictably定位每个标签区域的左上角。

So, does anyone have any suggestions on how to do an HTML/CSS layout that will precisely render on different types of printers? I don't really care if the line/word breaks are a bit different, but I need to be able to predictably position the upper left corners of each label area.

眼下标签表中的流下来的页面,我们已经调整了电池和内部资料核实的盒模型,使它们一致的高度。我怀疑是用每个元素的绝对定位可能是最好的答案,但是这将是棘手的,以及由于ASP.Net代标签的元素。如果我知道肯定会工作,我宁愿尝试不是抛出,我们必须去到一个不同的生成方法了一切。

Right now the labels flow down the page in a table and we have been tweaking the box model of the cells and internal DIVs to make them a uniform height. I suspect that using absolute positioning of each element may be the best answer, but that is going to be tricky as well due to the ASP.Net generation of the label elements. If I knew for sure that would work, I would rather try it than throw away everything we have to go to a different generation method.

轻微更新:
现在,我做了一些测试,绝对定位 - 仅设置顶部和左侧包含块元素的坐标。到目前为止,上有偏移到页面上的微小变化(边距,纸张对齐等),但所有的浏览器和打印机经过测试放在究竟正确的位置的元素相对于彼此。我AP preciate的PDF的提示,但没有人知道更多的陷阱关于使用绝对定位这样?

Slight Update: Right now I'm doing some tests with absolute positioning - setting only the top and left coordinate of a containing block element. So far there are minor variations on the offset onto the page (margins, paper alignment, etc.), but all browsers and printers tested put the elements in exactly the right spots relative to each other. I appreciate the PDF tips, but does anyone know of additional "gotchas" on using absolute positioning this way?

更新:
为了记录在案,我重写使用iTextSharp的标签打印部分和它完美的作品 - 绝对的方式做到这一点在未来...

Update: For the record, I rewrote the label printing portion using iTextSharp and it works perfectly - definitely the way to do this in the future...

推荐答案

忘记HTML做出了PDF。 HTML印刷是极具变化 - 不仅仅是跨浏览器的,但在不同版本的同一浏览器。 PDF是一个容易得多。

Forget HTML and make a PDF. HTML printing is extremely variable - not just across browsers but across different versions of the same browser. PDF is a lot easier.

即使你用正确的一个浏览器/字体设置/打印机/月相得到它究竟是,这将是你曾经不得不保持最脆弱的东西。无论多久你认为它会采取使PDF(并且也有一些免费的图书馆在那里它不是真的那么难),HTML将最终需要你的时间多很多。 PDF阅读器被广泛部署,甚至比Word文件打印更加一致。

Even if you get it exactly right with one browser / font setup / printer / phase of the moon, it will be the most fragile thing you've ever had to maintain. No matter how long you think it will take to make a PDF (and it's not really that hard as there are some free libraries out there), HTML will ultimately take a lot more of your time. PDF readers are widely deployed and print more consistently than even Word files.

这篇关于从网页打印条码code标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆