我无法打印到标签打印机.下面的代码在一个上打印4个"标签"(附加标签图片).
下面的代码打印到兄弟QL-500标签打印机.它打印到3.5"×1.1"标签上.
如果有人可以帮助我更好地理解代码,那也会很棒.
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import javax.print.PrintService;
public class DYMOLabelPrintConnector implements Printable {
public static final String PRINTERNAME = "DYMO LabelWriter 400";
public static final boolean PRINTMENU = false;
public static void main(String[] args) {
PrinterJob printerJob = PrinterJob.getPrinterJob();
PageFormat pageFormat = printerJob.defaultPage();
Paper paper = new Paper();
final double widthPaper = (1.2 * 72);
final double heightPaper = (1.5 …Run Code Online (Sandbox Code Playgroud) 我正在制作一个WordPress插件来与我们的图书馆系统集成.我正在尝试创建一个带有搜索表单的页面来搜索数据库.我在我们的库服务器上创建了一个API(它位于我们的本地网络上),因此该站点可以与我们的库后端进行交互.
我正在尝试对从API中提取的结果进行分页,数据在json中.我创建了以下代码来从API获取json并将其转换为PHP数组,它不实现搜索,但是:
add_shortcode("book_search_form", "book_search_form");
function book_search_form() {
$api_url = get_option('api_url');
$api_key = get_option('api_key');
$data = file_get_contents("$api_url/book/index.php/name/awesome/$api_key");
$data = (array)json_decode($data, true);
echo '<pre>';
var_dump($data);
echo '</pre>';
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
array(2) {
[0]=>
array(22) {
["barcode"]=>
string(12) "000015427928"
["name"]=>
string(74) "Janice VanCleave's 201 awesome, magical, bizarre & incredible experiments."
["author"]=>
string(12) "Janice Pratt"
["author_last"]=>
string(9) "VanCleave"
["publisher"]=>
string(11) "Wiley: 1994"
["year_pub"]=>
string(0) ""
["edition"]=>
string(0) ""
["genre"]=>
string(0) ""
["checkout"]=>
string(5) "false"
["series"]=>
string(0) ""
["callnum"]=>
string(5) "507.8"
["fiction"]=>
string(5) "false"
["in_house"]=>
string(5) …Run Code Online (Sandbox Code Playgroud) 我有以下脚本从API获取搜索结果,然后切片数组并转储它,我无法将JSON解码为数组,它返回Array(0) {
}
它是一个wordpress短代码
以下是从api获取的Json示例:
[
{
"barcode": "000015426950",
"name": "Karen's cowboy",
"author": "Ann",
"author_last": "Martin",
"publisher": "New York : Scholastic, c2000.",
"year_pub": "",
"edition": "",
"genre": "",
"checkout": "out",
"series": "",
"callnum": "MAR",
"fiction": "true",
"in_house": "false",
"timestamp": "1355835387",
"outto": "000008388615",
"duedate": "1372005722",
"ISBN": "059052528X",
"media_type": "",
"print": "false",
"BOXID": "2147483647",
"uid": "10",
"printed": ""
},
{
"barcode": "000015426949",
"name": "Karen's yo-yo",
"author": "Ann M",
"author_last": "Martin",
"publisher": "New York : Scholastic, c2000.",
"year_pub": "",
"edition": "",
"genre": …Run Code Online (Sandbox Code Playgroud)