Did you know that the Link-OS SDK has command line tools? You don't always need to create an app to do some pretty powerful things. Well created batch files can do some good things too. This Blog will go through a common use case for the SDK command line tools and how to implement it.
Recently a customer contacted us because they had an old tool they were using to automatically convert image files into Zebra downloadable image files. The old tool was not compatible with newer Windows versions and they were looking for an alternative without having to write an app themselves.
We recommended that they look at the command line tools attached to the SDK. Try this yourself... after installing the Link-OS SDK, navigate to the install folder then "/PC/[build version]/" and (PC)shift-right click the "lib" folder. Select "Open command window here". Then type "java -jar ZSDK_API.jar help". The SDK will give you a list of commands you can run from a command line. The PC.NET and new card printer SDKs for Java and .NET also have command line tools.
For this customer, I put together a sample batch file that they could modify to read all the files from one folder and convert them and put the new files in a different folder. The below batch file is fairly basic, but any IT person could modify it to change folder locations, automate running the file, or add options to set the output specific image sizes.
:: Batch file - convert.bat
:: Location of original image files. Can be .png, .jpg, .bmp, etc.
set src=C:\My Documents\Pictures\Test
:: Location of where you want the new ZPL converted files to go.
set dest=C:\My Documents\Pictures\Dest
:: Location of the actual Link-OS SDK file to use.
:: loop through each file in the source directory
for %%f in ("%src%\*") do (
:: show file name
:: show full command run through the SDK
@echo java -jar "%zsdk%" graphic "%%f" -n E:%%~nf.GRF -s "%dest%\%%~nf.grf" -v
:: Cammand options -call the SDK and give it the source file
:: -name it [filename].GRF in the printer, the extension specifies the file type to convert to (PNG also possible)
:: -save it to the destination folder using the same file name as the original
:: -verbose feedback
java -jar "%zsdk%" graphic "%%f" -n E:%%~nf.GRF -s "%dest%\%%~nf.grf" -v
Other things you can do with the command line tools are create and work with settings profiles, convert fonts, reset the printer, update Wi-Fi certificates, and, of course, several options to print.
Z:\Documents\link_os_sdk\PC\v2.14.5097\lib>java -jar ZSDK_API.jar help
ZebraLink Multiplatform SDK - Version 2.14.5097
usage: java -jar ZSDK_API.jar <commmand> [<args>]
backup - Creates a backup of the printer and stores it to the local file
certificate - Sends a certificate file directly to a Zebra printer.
clock - Set the Real-Time Clock.
config - Prints the configuration label.
convertfont - Converts a TTF/TTE font for storage on a Zebra Printer.
default - Restore printer defaults.
delete - Deletes a file on the printer's file system.
discover - Discover printers
get - Retrieves files from the printer.
graphic - Converts a graphic for storage on a printer
help - Get information about other commands
loadbackup - Loads backup onto printer. Will delete existing printer files.
loadprofile - Loads profile onto printer.
ls - Lists the files on the remote printer
mirror - Uploads a zprofile to a mirror server
print - Print XML or CSV files
profile - Creates a profile based on the printer
reset - Resets a printer
send - Sends data to the raw port on the printer
sendJSON - Sends JSON data to the printer
status - Retrieve the status of the printer
store - Stores a local file onto a printer.
template - Fill in a zpl/cpcl template file with xml or csv
update - Updates the firmware on the printer
weblink - Configures the weblink address
Graphic command options:
>java -jar ZSDK_API.jar graphic --help
usage: java -jar ZSDK_API.jar graphic <graphicFile> [<options>]
Converts a graphic for storage on a printer
-y/--height <height> - Image height in pixels
-x/--width <width> - Image width in pixels
-n/--name <fileName> - Name to save on the printer, if not given, will
default to E:IMG.GRF
-s/--save <filePath> - Save to a local file
-p/--printer <destination> - Printer to send the graphic to.
--tcp - Force connection to be made via TCP.
-d/--driver - Force connection to be made via ZDesigner Driver.
-h/--help - Print the help message
-v/--verbose - Verbose output
use --help option to display this message
We hope you find this information useful. Don't forget to like or rate this article!