Java card print example

S Saverio Pangallo 3 years 7 months ago
171 1 0

Hello,
can anyone provide a sample code to print a card with a text label, a barcode and an image using the Java SDK for ZXP Series Printers?
I went through some documents but it seems I can only print images.
The examples that comes with the SDK shows how to print images and templates. Is there a way to print directly without using the templates?
 
Any help would be very apreciated.
Thank you,
Saverio

Please Register or Login to post a reply

1 Replies

J Jean REBILLAT

I have had the same question.
I made a rough test to understand more the drawing process, using and deriving the SDK example.
My first test contains that part:

List graphicsData = new ArrayList();
            ZebraCardGraphics graphics = new ZebraCardGraphics(zebraCardPrinter); // Initialize graphics for ZXP Series printers
            graphics.initialize(0, 0, OrientationType.Landscape, PrintType.MonoK, Color.WHITE);
            byte[] frontSideImageData = FileUtils.readFileToByteArray(new File("C:\\Temp\\image16x9.png"));
            graphics.drawImage(frontSideImageData, 100, 100, 790, 500, RotationType.RotateNoneFlipNone);
            graphics.drawEllipse(150, 150, 700, 400, 5, Color.BLACK, null);
//          graphics.drawRectangle(300, 200, 424, 248, 1, Color.BLACK, null);
            graphics.drawText("This is a test", 300, 400, 424, 248, 0, Color.BLACK);
            GraphicsInfo grInfo = new GraphicsInfo();
            grInfo.graphicData = graphics.createImage();
            grInfo.graphicType = GraphicType.BMP;
            grInfo.side = CardSide.Front;
            grInfo.printType = PrintType.MonoK;
            graphicsData.add(grInfo);

            graphics.clear();
            int jobId = zebraCardPrinter.print(1, graphicsData);

This answers partially to your question : how to draw figures and text (but not barcodes).
Notice that trying to draw the rectangle always ends with a broken ribbon, this is why it is commented.

CONTACT
Can’t find what you’re looking for?