Digital signature provides authentication by encrypting the text with the sender's private key and decrypting the text with the sender's public key. But how do we add integrity to it so that the text sent by the sender does not vary at the receiving end?
Your question implies a slight misunderstanding. First, to clear that up: Digital signatures do not encrypt the original data. You can choose to both sign and encrypt the original data, but those are two totally distinct processes. I will address signed and encrypted messages at the end. The original data is called the plaintext below, which is the official term.
A standard digital signature works by hashing the plaintext first. For message signing, only the hash is encrypted. Since both the sender and the recipient can hash the plaintext, they should get the same result. A digital signature requires the sender to append the hash to message, and he encrypts the hash with his private key.
Since the sender encrypted the hash with his private key, the recipient knows that only the sender's public key will allow him to decrypt a hash that matches the plaintext. This is the essential concept behind signing.
In order to verify the plaintext, the recipient decrypts the hash attached to the message. Then he computes a hash for the plaintext on his own. If his computed hash matches the decrypted hash, then he knows the message has not been changed. If his computed hash does not match the decrypted hash, then the message cannot be trusted.
If the sender wants to encrypt the entire message, he can do that as well. He would simply encrypt the plaintext with the recipient's public key (the encrypted data is called ciphertext). Then he calculates a hash for the ciphertext, and he sends the ciphertext with an encrypted copy of the hash, just like a regular signed message. The process is similar for the recipient, except this time the recipient will use the hash to verify the ciphertext. If it matches, he will then decrypt the ciphertext into plaintext.