async Task <bool> EncodeDrivingLicense(ITask obj)
        {
            var o           = (DrivingLicense)obj;
            var holderPhoto = o.Holder.PhotoData;

            if (!String.IsNullOrEmpty(holderPhoto))
            {
                var photoData = Convert.FromBase64String(holderPhoto);
                using (var image = new MagickImage(photoData))
                {
                    image.Quality = 80;
                    image.Resize(275, 0);
                    o.Holder.PhotoData = image.ToBase64(MagickFormat.Jpeg);
                }
            }

            var holderSign = o.Holder.SignatureData;

            if (!String.IsNullOrEmpty(holderSign))
            {
                var signData = Convert.FromBase64String(holderSign);
                using (var image = new MagickImage(signData))
                {
                    image.Quality = 90;
                    image.Resize(165, 0);
                    image.BackgroundColor = MagickColors.White;
                    image.ColorAlpha(MagickColors.White);
                    o.Holder.SignatureData = image.ToBase64(MagickFormat.Jpeg);
                }
            }

            var jss = new JsonSerializerSettings
            {
                ContractResolver     = new DlPostContractResolver("card"),
                DateTimeZoneHandling = DateTimeZoneHandling.Local,
                DateFormatString     = "yyyyMMdd"
            };
            var json = JsonConvert.SerializeObject(o, Formatting.Indented, jss);

            int    rsCode;
            string cardSn;

            try
            {
                rsCode = await CardApi.WriteDriverInfo(json);

                cardSn = await CardApi.ReadUUidAsync();
            }
            catch
            {
                CurrentProdLine.SetPrinterPosition("RejectPosition");
                rtbLog.AppendText(String.Format(Texts.CardEncodingError, DateTime.Now.ToString("G")));
                rtbLog.AppendText(Environment.NewLine);
                return(false);
            }

            if (rsCode != 0)
            {
                CurrentProdLine.SetPrinterPosition("RejectPosition");
                rtbLog.AppendText(String.Format(Texts.CardEncodingError, DateTime.Now.ToString("G")));
                rtbLog.AppendText(Environment.NewLine);
                return(false);
            }

            o.CardSn               = cardSn;
            o.Holder.PhotoData     = holderPhoto;
            o.Holder.SignatureData = holderSign;
            return(true);
        }