0 Replies Latest reply on Apr 17, 2019 8:00 AM by Anedeor Dofcoo

    ZC300 Barcode Print Error

    Anedeor Dofcoo

      Hello, I have some problem with LINK-OS SDK: I can't print Barcodes!

      The others elements (Image, Text, Shape) were printed, but when I try to print a Barcode it print my method parameters (DrawBarcode) on the card!

      IMG_20190417_164232.jpg

       

      This is my C# code (taked from GitHub - Zebra/LinkOS-PCCard-Samples at ConnectAndPrint_ZXPSeries1and3_C#  and GitHub - Zebra/LinkOS-PCCard-Samples at CenterBarcode_ZXPSeries3_C# ):

       

                  int errValue;   // value of 0 indicates no errors
                  msg = string.Empty;
                  try
                  {
                      if (InitGraphics(_asciiEncoder.GetBytes(drvName), out errValue) == 0)
                      {
                          msg = "Printing InitGraphics Error code: " + errValue.ToString();
                          return;
                      }
      
                      int rotation = 0; // origin lower left and no rotation
                      int barcodeType = 0; // Code 39
                      int barcodeWidthRatio = 2; // narrow bar = 2 dots, wide bar = 5 dots
                      int barcodeMultiplier = 2; // {2..9}
                      int barcodeHeight = 75; // 75 dots
                      int textUnder = 1; // true
                      string barcodeData = "123456789";
      
                      //To calculate the full length of a Code 39 bar code:
                      //L = [(C+2) (3R + 7) - 1] X Where 
                      //L = Length of bar code
                      //C = Number of characters
                      //R = Ratio of wide-to-narrow bars
                      //X = Number of dots times 0.0033 inches per dot (0.08847 mm per dot); for the 5:2 ratio, X = Dots times 2
                      //See ZXP3 SDK Manual for the forumulas used to calcuate the length of other barcode types.
      
                      // Calculate the length of the barcode
                      int C = barcodeData.Length;
                      double R = 5.0 / 2.0;
                      int X = 2;
                      int length = (int)((C + 2) * (3 * R + 7) - 1) * X;
      
                      int startX = (int)Math.Floor((CARD_WIDTH - length) / 2.0); //Center barcode horizontally
                      int startY = (int)Math.Floor(((CARD_HEIGHT - barcodeHeight) / 2.0) + barcodeHeight); //Center barcode vertically
      
                      // Sends Barcode data to the Monochrome Buffer
                      if (DrawBarcode(startX, startY, rotation, barcodeType, barcodeWidthRatio, barcodeMultiplier, barcodeHeight, textUnder, _asciiEncoder.GetBytes(barcodeData), out errValue) == 0)
                      {
                          msg = "Printing DrawBarcode Error: " + errValue.ToString();
                          return;
                      }
                     // Prints the Graphics Buffer (Front Side)
                      if (PrintGraphics(out errValue) == 0)
                      {
                          msg = "Printing PrintGraphics Error code: " + errValue.ToString();
                          return;
                      }
                  }
                  catch (Exception ex)
                  {
                      msg += "PrintJob threw exception " + ex.ToString();
                  }
                  finally
                  {
                      // Starts the printing process and releases the Graphics Buffer
                      if (CloseGraphics(out errValue) == 0)
                      {
                          msg = "Printing CloseGraphics Error: " + errValue.ToString();
                      }
                  }
      

       

      Please help!