【发布时间】:2017-04-14 13:58:31
【问题描述】:
我跟随this/this在EPSON Printer的部分POS(销售点)打印收据
在这里,我从 URL 获取数据 Json(在 Json 对象中,我正在获取 html 打印模板):
{
"response": {
"status": "<table>.... </table>"
}
}
所以我有意使用上述 json 对字符串的响应并将其转换为 html:
method = "addFeedLine";
mPrinter.addFeedLine(1);
textData.append("Test print Sample string\n");**//this is sample text**
textData.append(Html.fromHtml(status + "\n"));
**//this is JSON response which is nothing but HTML code, so I am converting it to string**
在那里,我使用了status 作为字符串,因此无论该字符串中的内容是什么,它都会被打印出来。
如果不是html而只是纯文本,我会这样打印
method = "addFeedLine";
mPrinter.addFeedLine(1);
textData.append(status);
这是status 的示例
"status": "The store list Sample\nSTORE DIRECTOR – XYZ\n01/01/01 16:58 6153 05 0191 134\nST# 21 OP# 001 TE# 01 TR# 747\n------------------------------\n400 OHEIDA 3PK SPRINGF 9.99 R\n410 3 CUP BLK TEAPOT 9.99 R\n445 EMERIL GRIDDLE/PAN 17.99 R\n438 CANDYMAKER ASSORT 4.99 R\n474 TRIPOD 8.99 R\n433 BLK LOGO PRNTED ZO 7.99 R\n458 AQUA MICROTERRY SC 6.99 R\n493 30 L BLK FF DRESS 16.99 R\n407 LEVITATING DESKTOP 7.99 R\n441 ** Blue Overprint P 2.99 R\n476 REPOSE 4 PCPM CHOC 5.49 R\n461 WESTGATE BLACK 25 59.99 R\n------------------------------\nSUBTOTAL 160.38\nTAX 14.43\nTOTAL 174.81\nCASH 200.00\nCHANGE 25.19\n------------------------------\nPurchased item total number\nSign Up and Save!\nWith Preferred Saving Card\n"
现在,我有一个纯 HTML 页面:
Search Images Maps Play YouTube News Gmail Drive More »
Web History | Settings | Sign in
Louisa May Alcott’s 184th birthday
[ ] Advanced
searchLanguage
[Google Search][I'm Feeling Lucky] tools
Advertising ProgrammesBusiness Solutions+GoogleAbout GoogleGoogle.com
© 2016 - Privacy - Terms
我需要从 url 打印这个。
谁能建议我如何打印这个纯文本? 没有 HTML 标签,也没有 JSON 数据。
【问题讨论】:
-
那些提到的链接无法访问..所以最好发布您正在使用的 sdk 的名称和正确描述,而不是像您那样引用链接。
-
我在底部更新了链接,我们有 sdk 的下载链接.....所有投反对票的人请投票,所有答案的人请投票我已经在赏金中放松了
标签: android html url printing plaintext