- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试将 HTML 代码转换为 JPEG 图像。它有点管用,但当我尝试使用条形码时却不行。
服务器端,我正在使用:
我正在使用 CODE128 协议(protocol)对 EAN133 条码进行编码,当我想在网页上显示它时它可以工作(我使用 HttpUtility.HtmlEncode(code_barre)
所以条码被很好地解释),然后我使用条形码字体来显示条形码,这就是我的图像有问题的地方:
如您所见,它是格式良好的“纯文本”条码,并具有以下 CSS:
@font-face { font-family: 'code_128regular'; src: url('/Assets/Fonts/code128-webfont.eot'); src: url('/Assets/Fonts/code128-webfont.eot?#iefix') format('embedded-opentype'), url('/Assets/Fonts/code128-webfont.woff2') format('woff2'), url('code128-webfont.woff') format('woff'), url('/Assets/Fonts/code128-webfont.ttf') format('truetype'), url('/Assets/Fonts/code128-webfont.svg#code_128regular') format('svg'); font-weight: normal; font-style: normal;} .test{font-family:'code_128regular'; font-size:70px;}
我应该变成这样:
但它不会,即使我使用相对路径导入 Bootstrap CSS,而当我尝试使用 IronPDF 生成 PDF 时它会起作用
感谢关注
编辑:这是生成的 HTML:
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<link rel='stylesheet' type='text/css' href='Assets/Bootstrap/css/bootstrap.min.css'>
<script type='text/javascript' src='Assets/Bootstrap/js/bootstrap.min.js'></script>
</head>
<style>
@font-face {
font-family: 'code_128regular';
src: url('/Assets/Fonts/code128-webfont.eot');
src: url('/Assets/Fonts/code128-webfont.eot?#iefix') format('embedded-opentype'), url('/Assets/Fonts/code128-webfont.woff2') format('woff2'), url('code128-webfont.woff') format('woff'), url('/Assets/Fonts/code128-webfont.ttf') format('truetype'), url('/Assets/Fonts/code128-webfont.svg#code_128regular') format('svg');
font-weight: normal;
font-style: normal;
}
.test {
font-family: 'code_128regular';
font-size: 70px;
}
</style>
<center><p class='test'>ÌMXCUTGRIP305-07DÎ</p><p>MXCUTGRIP305-07</p></center>
</html>
最佳答案
NReco ImageGenerator 在内部使用 wkhtmltoimage 命令行工具,因此实际上您可以期待相同的行为。在您的情况下,由于某种原因,您的自定义字体似乎被 wkhtmltoimage 忽略了;首先尝试使用 woff、woff2 或 ttf 字体文件而不是 eot。如果您使用接受 HTML 作为 .NET 字符串的“GenerateImage”方法,则所有外部引用都应该是绝对的。
以下 HTML 模板对我来说效果很好(我使用了来自谷歌字体的“Libre Barcode 128”):
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Libre+Barcode+128&lang=en" />
</head>
<style>
.test {
font-family: 'Libre Barcode 128';
font-size: 70px;
}
</style>
<center><p class='test'>ÌMXCUTGRIP305-07DÎ</p><p>MXCUTGRIP305-07</p></center>
</html>
关于html - NReco imagegenerator 无法正确写入条形码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46911493/
我正在尝试将 HTML 代码转换为 JPEG 图像。它有点管用,但当我尝试使用条形码时却不行。 服务器端,我正在使用: 我正在使用 CODE128 协议(protocol)对 EAN133 条码进行编
我建了一个 型号 它由两个分支组成,然后合并为一个。对于模型的训练,我想使用 ImageGenerator 来扩充图像数据,但不知道如何为混合输入类型工作。有人知道如何在 keras 中处理这个问题吗
简介 我正在使用可以将“html”转换为图像的功能。对于图像创建,我使用(System.Drawing 的)“Image”函数。 Functionality working fine(includin
我搜索了类似的问题,但没有找到我想要做的解决方案。 我有 16 位灰度图像,我正在尝试将它们放入 keras ImageDataGenerator。当使用像:flow_from_dataframe 这
我目前正在尝试遵循示例 here使用我自己生成的数据集。后端使用 Theano 运行。目录结构完全相同: image_sets/ dogs/ dog001.jpg
我是一名优秀的程序员,十分优秀!