简体   繁体   English

直接在(斑马)打印机上的浏览器中打印标签/条形码标签

[英]Print sticker/barcode label directly from browser on a (zebra) printer

We have to following situation, for one of our clients we are looking for a solution. 我们必须遵循以下情况,对于我们的一位客户,我们正在寻找解决方案。 He has build an PHP script that generates a label with some info and barcodes on it, so the workflow is as discribed : User put in some data ( some is data is pulled from the database, some not ) 他构建了一个PHP脚本,该脚本会生成带有一些信息和条形码的标签,因此工作流程如下所述:用户输入了一些数据(有些是从数据库中提取的,有些不是)

When the user clicks on print label, a windows opens and the label is generated. 当用户单击打印标签时,将打开一个窗口并生成标签。 So now the code ( i guess javascript can do the job ) must do the work. 因此,现在代码(我想用javascript可以完成工作)必须完成工作。 The client wants that when the user clicks on ok ( or print label ) the label will be printed and the window will close without any interuption from a user. 客户希望当用户单击“确定”(或“打印标签”)时,标签将被打印并且窗口将关闭而不会受到用户的干扰。

Possible solution : http://dymodevelopers.wordpress.com/2010/06/02/dymo-label-framework-javascript-library-samples-print-a-label/ 可能的解决方案: http : //dymodevelopers.wordpress.com/2010/06/02/dymo-label-framework-javascript-library-samples-print-a-label/

So in fact : 所以实际上:

  1. The script must select the right printer ( not the default one ) 该脚本必须选择正确的打印机(不是默认打印机)
  2. Script must select the right format ( landscape/portrait and sizes of the labels ) 脚本必须选择正确的格式(横向/纵向和标签大小)
  3. Must be printed without user interuption. 必须在没有用户干扰的情况下进行打印。
  4. Window must close automatic after printing the label. 打印标签后,窗口必须自动关闭。

Thanks for the help ;) 谢谢您的帮助 ;)

I do exactly this but due to the limitations of web based stuff cannot control the windows print interface without either firing a java or an activex based sub app I have had to have the web browsers set to print to the dymo printers. 我正是这样做的,但是由于基于Web的东西的局限性,如果不触发Java或基于Activex的子应用程序就无法控制Windows打印界面,我不得不将Web浏览器设置为打印到dymo打印机。

Now I enforce the usage of firefox which means I have a custom install bundle of firefox that sets the margins to zero, turns off headers and footers, selects the right printer and paper and landscape etc (I only did a custom bundle because I had 100+ pc's to configure if its only a few its a 60 second change job to do it manually). 现在我强制使用firefox,这意味着我有一个自定义安装的firefox软件包,该软件包将页边距设置为零,关闭页眉和页脚,选择正确的打印机和纸张以及横向等(我只做了一个自定义软件包,因为我有100 + pc进行配置(如果仅几秒钟,则需要60秒的更改工作才能手动完成)。 The advantage of enforcing firefox is that FF allows you to select and set as the default printer a different printer to the system default. 启用firefox的优点是FF允许您选择其他打印机并将其设置为系统默认打印机,并将其设置为默认打印机。 So in my case ff is set for dymo's the system printer is set as the kyocera's so nothing gets lost/set etc outside of firefox. 因此,在我的情况下,将ff设置为dymo,将系统打印机设置为kyocera,以便在Firefox之外没有丢失/设置等。

As for generating the barcode I just create a basecode as a jpg on the fly display the jpg in a new popup window and use a little javascript to automatically popup the print box so all the user has to do is click ok. 至于生成条形码,我只是动态创建了一个jpg格式的基本代码,将jpg格式显示在新的弹出窗口中,并使用一些JavaScript自动弹出了打印框,因此用户要做的就是单击ok。 Its impossible to do this without user input! 没有用户输入就不可能做到这一点!

Unfortunately there's no easy way so close the window as there's no return event trap from the system print spooler/drivers back into the web browsers (they're sandboxed from each other for obvious reasons!) so the best you can do is implement a timed close after xxx seconds. 不幸的是,没有简单的方法可以关闭窗口,因为没有从系统打印后台处理程序/驱动程序返回到Web浏览器的返回事件陷阱(出于明显的原因,它们相互沙盒化!),所以您能做的最好的事情就是实现定时xxx秒后关闭。

Short of it though is there's no easy way to do this with no user input and without making a few compromises. 缺少它是没有用户输入且没有做出任何妥协的简单方法。 Now if cash and time is of no issue to you I do have a proper way of doing it fully automated etc but its a big job 现在,如果现金和时间对您来说不成问题,我确实有适当的方法可以使其完全自动化等,但这是一项很大的工作

我们只使用一个FTP(曾经使用过Windows,现在使用的是冷聚变内置的东西,但是可以使用),然后您将zebra打印机的条形码定义发送给zebra打印机……任何可以打开这样的窗口通道并将代码发送到打印机将可以正常工作..因此,如果您想使用javascript进行操作,请查看fireftp是如何工作的...然后使用它...或者您可以使用ZPLII编码发送信息...告诉它如何打印。

Since the link you posted talks about driver requirements, I assume you have a fair amount of control over the machine's software? 由于您发布的链接谈论驱动程序要求,因此我认为您对机器的软件有相当多的控制权吗? If that's the case and you can use Firefox, then an add-on called JS Print Setup may work. 如果是这样,并且您可以使用Firefox,则可以使用名为JS Print Setup的加载项。

It basically gives webpages the ability to print directly to a printer on the user's computer without a print dialog. 基本上,它使网页无需打印对话框即可直接打印到用户计算机上的打印机。

I assume it would print a label fine as long as the right size is provided, but I haven't tested that. 我认为只要提供正确的尺寸,它就能很好地打印标签,但是我还没有测试过。 I did test it when a printer wasn't connected and it did send it to that printer's queue, so definitely tells the system to print the file. 当没有连接打印机时,我确实对其进行了测试,并且确实将其发送到该打印机的队列中,因此可以肯定地告诉系统打印文件。

Here is a code sample from the documentation: (It appears that it lets you set margins and everything as well.) 这是文档中的代码示例:(看来它还允许您设置边距和所有内容。)

<script>
// set portrait orientation
jsPrintSetup.setOption('orientation', jsPrintSetup.kPortraitOrientation);

// set top margins in millimeters
jsPrintSetup.setOption('marginTop', 15);
jsPrintSetup.setOption('marginBottom', 15);
jsPrintSetup.setOption('marginLeft', 20);
jsPrintSetup.setOption('marginRight', 10);

// set page header
jsPrintSetup.setOption('headerStrLeft', 'My custom header');
jsPrintSetup.setOption('headerStrCenter', '');
jsPrintSetup.setOption('headerStrRight', '&PT');

// set empty page footer
jsPrintSetup.setOption('footerStrLeft', '');
jsPrintSetup.setOption('footerStrCenter', '');
jsPrintSetup.setOption('footerStrRight', '');

// clears user preferences always silent print value
// to enable using 'printSilent' option
jsPrintSetup.clearSilentPrint();

// Suppress print dialog (for this context only)
jsPrintSetup.setOption('printSilent', 1);

// Do Print 
// When print is submitted it is executed asynchronous and
// script flow continues after print independently of completetion of print process! 
jsPrintSetup.print();

// next commands
</script>

The add-on can be found here on Mozilla's add-on site: 可以在Mozilla的附加站点上找到该附加项:

https://addons.mozilla.org/en-US/firefox/addon/js-print-setup/ https://addons.mozilla.org/zh-CN/firefox/addon/js-print-setup/

Never used it myself but Seagull Scientific' BarTender seems like a good solution for direct printing of barcodes. 我自己从未使用过它,但Seagull Scientific的BarTender似乎是直接打印条形码的不错的解决方案。 It includes embedded drivers for working with databases such as Oracle, MS SQL, and .NET platform and offers Commander for printing from PHP web apps. 它包括用于与Oracle,MS SQL和.NET平台等数据库一起使用的嵌入式驱动程序,并提供Commander以便从PHP Web应用程序进行打印。 Tutorial for printing through PHP apps here http://cases.azoft.com/bartender-print-server/ 通过PHP应用程序打印的教程,请参见http://cases.azoft.com/bartender-print-server/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM