使用 PHP 打印 - 不同的字体大小? [英] Printing with PHP - Different font sizes?

查看:75
本文介绍了使用 PHP 打印 - 不同的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一所学校工作,正在为我们的服务台编写一个巫师风格的前端.学生将拿起平板电脑,填写他们的姓名,选择他们遇到的问题,然后系统会打开一张票.

I work at a school and am writing a wizard-style front end for our helpdesk. Students will grab the tablet, fill in their name, pick the issue they're having and a ticket will be opened on the system.

我们在办公桌上共享了一台收据打印机,并且使用 PHP 的 printer_* 函数,我可以使用 RAW 模式打印出简单的收据.学生将收据带回课堂,向老师展示他们与我们在一起的证明.到目前为止,我的代码运行良好:

We have a receipt printer shared at the desk and using PHP's printer_* functions, I'm able to print out simple receipts using RAW mode. The student will take the receipt back to class to show the teacher as proof they were with us. So far my code works great:

$handle = printer_open("EPSON TM-T88IV Receipt"); // The name of our printer on Windows
printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_CUSTOM); // Custom paper format
printer_set_option($handle, PRINTER_PAPER_WIDTH, "80"); // 80mm wide
printer_set_option($handle, PRINTER_MODE, "RAW"); // And raw printing mode
printer_write($handle, "Hello world\nPrinting is fun\nGoodbye"); // Sample text
printer_close($handle);

但我想知道的是,我如何进行花哨的格式设置,例如更大的字体大小、粗体文本甚至可能是徽标?(后者,不是那么重要,它只是一个愿望清单的东西)

But what I'd like to know is, how do I do fancy formatting, such as a larger font size, bold text or possibly even a logo? (the latter, not so important, it's just a wishlist thing)

我看到您可以将模式设置为文本和 EMF(增强型元文件格式?),但似乎找不到关于从 PHP 生成 EMF 的太多信息.我在一些网站上看到过转义码,但这些似乎是特定于打印机的,不是人类可读的.

I see you can set the modes to text and EMF (Enhanced Metafile Format?), but can't seem to find much info on generating EMF from PHP. I've seen escape codes on a few sites, but these seem to be printer specific and not human readable.

有什么建议吗?

推荐答案

看来你应该同时使用这两个函数 printer_create_fontprinter_draw_test,您将能够使用它们(来自 PHP 手册的代码):

It seems you should use both functions printer_create_font and printer_draw_test and you will be able using them something like this (code from PHP manual):

<?php
$handle = printer_open();
printer_start_doc($handle, "My Document");
printer_start_page($handle);

$font = printer_create_font("Arial", 72, 48, 400, false, false, false, 0);
printer_select_font($handle, $font);
printer_draw_text($handle, "test", 10, 10);
printer_delete_font($font);

printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);
?>

这篇关于使用 PHP 打印 - 不同的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆