# How to center text on Card?

**Joshua Preston**Jan 4, 2018 1:14 PM

I am having trouble center aligning text on a card for a Zebra ZXP Series 3 using the Card Printing SDK.

I found in one of your examples codes how to center a barcode for the Card. But how can I center text for a card?

For example, for a barcode its:

** // Barcode Drawing---------------------------------------------------**

** 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;**

** }**

But **how** and **where** can i find the formula for centering a label / text on a card??? It says it's in the manual but it isn't can someone please provide this formula?