我想在Django网站中添加条形码生成,并想知道最好的库或api是什么.我的第一个偏好是可以从Python调用的东西 - 用Python编写或C/C++ lib,我可以用ctypes/SWIG包装.否则,如果必须,我可以调用命令行.
我至少需要EAN和UPC符号.
我试过pybarcode但图像质量太低了.而且Elaphe看起来很有希望,但是从Python解释器我可以做的只是一个QR码 - EAN和UPC错误(可能是因为文档中的语法/用法不清楚).
这个线程已经很老了,但万一其他人正在寻找这个问题的答案...... code39 是一种字体,就像大多数类型的条形码一样。您可以简单地使用谷歌字体: https://fonts.google.com/specimen/Libre+Barcode+39+Extended+Text ?selection.family=Libre+Barcode+39+Extended+Text
除了该选项之外,您还可以托管静态文件,一个解决方案可能是 github 上的这个项目:
https://github.com/Holger-Will/code-39-font
在该项目中,您需要的只是与所需大小关联的文件以及 code39_all.css 文件。如果你愿意的话,其余的你可以删除。
为了供您参考,我在这里使用两者:
{% load staticfiles %}
{% load static %}
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Libre+Barcode+39+Extended+Text" rel="stylesheet">
<link rel="stylesheet" href="{% static 'code-39-font-master/code39_all.css' %}"/>
</head>
<body>
<style>
body {
font-family: 'Libre Barcode 39 Extended Text', cursive;
font-size: 48px;
}
</style>
<div>I'm just a code39 google font</div>
<div><class="code_39_S">I'm generated with static files!</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6009 次 |
| 最近记录: |