- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在创建一个程序,它将打印从商店购买的元素的 .txt 收据它打印成功,但我需要更改文本某些特定部分的字体,这可能吗?例如我想打印这样的东西
THIS SHOULD BE BOLD and BIGGER
this should be smaller than the first line
This should be italicized
有可能吗?
更新
这是打印过程的代码
public static void main(String[] args) throws PrintException, IOException {
String defaultPrinter =PrintServiceLookup.lookupDefaultPrintService().getName();
System.out.println("Default printer: " + defaultPrinter);
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
FileInputStream in = new FileInputStream(new File("sample.txt"));
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(new Copies(1));
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc doc = new SimpleDoc(in, flavor, null);
DocPrintJob job = service.createPrintJob();
PrintJobWatcher pjw = new PrintJobWatcher(job);
job.print(doc, pras);
pjw.waitForDone();
in.close();
// send FF to eject the page
InputStream ff = new ByteArrayInputStream("\f".getBytes());
Doc docff = new SimpleDoc(ff, flavor, null);
DocPrintJob jobff = service.createPrintJob();
pjw = new PrintJobWatcher(jobff);
jobff.print(docff, null);
pjw.waitForDone();
}
}
class PrintJobWatcher {
boolean done = false;
PrintJobWatcher(DocPrintJob job) {
job.addPrintJobListener(new PrintJobAdapter() {
public void printJobCanceled(PrintJobEvent pje) {
allDone();
}
public void printJobCompleted(PrintJobEvent pje) {
allDone();
}
public void printJobFailed(PrintJobEvent pje) {
allDone();
}
public void printJobNoMoreEvents(PrintJobEvent pje) {
allDone();
}
void allDone() {
synchronized (PrintJobWatcher.this) {
done = true;
System.out.println("Printing done ...");
PrintJobWatcher.this.notify();
}
}
});
}
public synchronized void waitForDone() {
try {
while (!done) {
wait();
}
} catch (InterruptedException e) {
}
}
最佳答案
Bold 示例(假设您的打印机具有与链接到的代码相同的转义序列)。
public static final char ESC = 27;
public static final String BOLD_ON = ESC + "E";
public static final String BOLD_OFF = ESC + "F";
String textString = "some text";
String toPrintInBold = BOLD_ON + textString + BOLD_OFF;
现在 toPrintInBold
已准备好设置到打印机。
如果它有效,那么你就有了一个方法,只需要更多的控制代码。
关于来自 .txt 的 Java 收据文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24793655/
我一直在尝试学习Grails,但是我遇到了以下问题。我已经创建了四个域类(Receipts,Items,类别和所有者),并且为每个域类(ReceiptsController,ItemsControll
我正在构建一个销售点应用程序,我想打印一张收据。问题是我使用的打印机无法打印纯文本的任何图形,我在 javafx 中只能找到使用 Print API 打印节点或使用像 jasper 这样都包含图形的报
我正在 Swift 3.0 应用程序中实现应用程序内购买,因此我需要获取应用程序收据以根据 iTunes 商店对其进行验证。这是我获得收据的方式: func getReceipt() -> Data?
我想在我的数据库中保存非消耗品的 IAP 收据。我们有一个用于 IAP 恢复的两步下载机制。 使用 StoreKit 机制检索所有交易(包括收据)。 从所有收据(即这些收据背后的产品)列表中选择稍后要
我想验证 iOS 收据。 我想我会向 App Store 验证服务器发送收据(https://sandbox.itunes.apple.com/verifyReceipt 或 https://buy.
我需要打印具有相同产品数量等的销售订单的 POS 收据 在销售订单中,我创建了一个按钮“打印 POS 收据”。使用此按钮,我想触发一种方法,该方法打印出带有销售订单行的收据。 所以我需要找到创建 PO
我们现在有一个正在生产中的应用程序,它会将 IAP 收据发送到我们的服务器,这些收据显然太短,而且我们的服务器没有经过 apple 的验证。 Apple 正确验证的长收据长度为 3192。短收据长度均
我正在构建一个 iOS 应用程序,它提供我们网站已经提供的服务。这是一项基于订阅的服务,订阅后所有功能都会启用。为了让人们在应用程序上注册定期付款,我似乎必须通过 Apple 的应用程序内购买 API
我需要一种方法来捕获笔记本中打印的所有内容。 为什么? 我有一个 PHP 系统,有时我需要打印(php_printer) 一些发票,但这会花费很多纸张。 打印在后台发送,没有任何弹出窗口供用户确认。
我对此有点困惑。所以关注this approach我得到了包含一堆解密字段的 json。其中 original_purchase_date。 我需要的是跟踪在这个新版本免费之前是否购买了应用程序,我认
首先,我说的不是调用https://buy.itunes.apple.com/verifyReceipt/ ,相反,我要问的是如何验证来 self 们的一位用户的 iTuneStore 收据。 我们的
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 5 年前。
所以我要建立一个在线商店,我想向客户发送包含收据的订单确认。我搜索了一下,但我还没有设法创建任何东西。 这是我发现并尝试使用的东西,但没有成功创建任何东西。 所以 ajax 调用会将 cartCon
所以我要建立一个在线商店,我想向客户发送包含收据的订单确认。我搜索了一下,但我还没有设法创建任何东西。 这是我发现并尝试使用的东西,但没有成功创建任何东西。 所以 ajax 调用会将 cartCon
我正在尝试实现自动续订订阅。我的应用程序可以在不同的设备(Android、Web)上使用,因此我需要实现状态轮询技术,以便在 App Store 设法续订过期订阅时确认我的服务器。收据正在我的服务器上
我正在尝试验证来自 C++ 服务器的 iphone 收据(我有使用 base64 加密的收据,我正在根据苹果文档编写一个 json 对象,然后我打开一个到沙箱的套接字并发送一个 POST请求)。 服务
首先,这个问题与 iOS7+ 收据有关,因此所有关于 latest_receipt 和 latest_receipt_info 的问题/答案都不适用(因为它们已被弃用并且正在离开)。似乎关于在 SO
谁能告诉我如何使用 Exchange Web 服务 API 获取电子邮件正文、收据、发件人、抄送信息?我只知道如何获取主题。 ExchangeService service = new Exchang
有关服务器到服务器通知的 Apple 文档没有指定 cancellation_date 字段中的数据格式。我正在尝试为我的通知处理程序设置一些单元测试,但我不确定要将哪些数据放入我的模拟响应中。 我假
我正在尝试使用 Citizen CT-S651 热敏打印机从网络浏览器打印 HTML/CSS 媒体格式的收据。我们已经能够正确格式化收据,但问题是在打印收据后,打印机继续吐纸而不是在内容的末尾切割。
我是一名优秀的程序员,十分优秀!