1 Reply Latest reply on Oct 23, 2017 12:03 AM by Jean REBILLAT

    Java card print example

    Saverio Pangallo

      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

        • Re: Java card print example
          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<GraphicsInfo> graphicsData = new ArrayList<GraphicsInfo>();

                      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.