Я пытаюсь создать несколько меток, добавляя только один код ZPL с несколькими метками, но когда я ввожу код ZPL, он генерирует только первую. Помогите мне, пожалуйста
try (Scanner scanner = new Scanner(System.in)) {
System.out.println("Enter ZPL (type 'exit' to finish):");
String zpl = scanner.nextLine();
int labelIndex = 0; // Start with label index 0
while (!zpl.equalsIgnoreCase("exit")) {
// Adjust print density (8dpmm), label width (4 inches), label height (6 inches), and label index as necessary
URI uri = URI.create("https://api.labelary.com/v1/printers/8d ... 1x5.90551/" + labelIndex + "/");
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Accept", "application/pdf") // omit this line to get PNG images back
.POST(HttpRequest.BodyPublishers.ofString(zpl))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
byte[] body = response.body();
if (response.statusCode() == 200) {
File file = new File("label_" + labelIndex + ".pdf"); // Change file name for PNG images
Files.write(file.toPath(), body);
System.out.println("Label_" + labelIndex + " created successfully.");
} else {
String errorMessage = new String(body, StandardCharsets.UTF_8);
System.out.println("Failed to create label: " + errorMessage);
}
// Read the next ZPL input
System.out.println("Enter next ZPL (type 'exit' to finish):");
zpl = scanner.nextLine();
labelIndex++; // Increment label index for the next label
}
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... ple-labels
ZPL API не генерирует несколько меток ⇐ JAVA
Программисты JAVA общаются здесь
1713554639
Anonymous
Я пытаюсь создать несколько меток, добавляя только один код ZPL с несколькими метками, но когда я ввожу код ZPL, он генерирует только первую. Помогите мне, пожалуйста
try (Scanner scanner = new Scanner(System.in)) {
System.out.println("Enter ZPL (type 'exit' to finish):");
String zpl = scanner.nextLine();
int labelIndex = 0; // Start with label index 0
while (!zpl.equalsIgnoreCase("exit")) {
// Adjust print density (8dpmm), label width (4 inches), label height (6 inches), and label index as necessary
URI uri = URI.create("https://api.labelary.com/v1/printers/8dpmm/labels/3.93701x5.90551/" + labelIndex + "/");
HttpRequest request = HttpRequest.newBuilder(uri)
.header("Accept", "application/pdf") // omit this line to get PNG images back
.POST(HttpRequest.BodyPublishers.ofString(zpl))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
byte[] body = response.body();
if (response.statusCode() == 200) {
File file = new File("label_" + labelIndex + ".pdf"); // Change file name for PNG images
Files.write(file.toPath(), body);
System.out.println("Label_" + labelIndex + " created successfully.");
} else {
String errorMessage = new String(body, StandardCharsets.UTF_8);
System.out.println("Failed to create label: " + errorMessage);
}
// Read the next ZPL input
System.out.println("Enter next ZPL (type 'exit' to finish):");
zpl = scanner.nextLine();
labelIndex++; // Increment label index for the next label
}
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78355811/zpl-api-not-generating-multiple-labels[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия