Пример #1
0
    /// <summary>
    /// Encode text in to a QR Code and define the colors and the Errer Correction Level
    /// </summary>
    /// <param name="text"></param>
    /// <param name="darkColor"></param>
    /// <param name="lightColor"></param>
    /// <param name="errorCorrectionLevel"></param>
    /// <returns></returns>
    public static Texture2D EncodeString(string text, Color darkColor, Color lightColor, QRCodeGenerator.ECCLevel errorCorrectionLevel)
    {
        QRCodeGenerator qrGenerator = new QRCodeGenerator();
        QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(text, errorCorrectionLevel);

        Texture2D qrTexture = qrCode.GetGraphic(PIXELS_PER_MODULE, darkColor, lightColor);

        return qrTexture;
    }
Пример #2
0
    /// <summary>
    /// Encode text in to a QR Code
    /// </summary>
    /// <param name="text"></param>
    /// <returns></returns>
    public static Texture2D EncodeString(string text)
    {
        QRCodeGenerator qrGenerator = new QRCodeGenerator();
        QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.L);

        Texture2D qrTexture = qrCode.GetGraphic(PIXELS_PER_MODULE);

        return qrTexture;
    }
Пример #3
0
 void GenerateQR(string value)
 {
     QRCodeGenerator qrGenerator = new QRCodeGenerator();
     QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(value, QRCodeGenerator.ECCLevel.Q);
     using (Bitmap bitMap = qrCode.GetGraphic(20))
     {
         using (MemoryStream ms = new MemoryStream())
         {
             bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
             byte[] byteImage = ms.ToArray();
             imgQR.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
         }
     }
 }
Пример #4
0
        public QRLinkWindow(PedroFileDownload fileData)
        {

            InitializeComponent();
            //PayloadGenerator.Url url2 = new PayloadGenerator.Url("www.google.es");
            PayloadGenerator.Url url = new PayloadGenerator.Url(fileData.Url + @"/index.html");
            //PayloadGenerator.WiFi wifiPayload = new PayloadGenerator.WiFi("MyWiFi-SSID", "MyWiFi-Pass", PayloadGenerator.WiFi.Authentication.WPA);
            QRCodeGenerator.ECCLevel  eccLevel= QRCodeGenerator.ECCLevel.L;
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            //QRCodeData qrCodeData = qrGenerator.CreateQrCode(@fileData.Url+@"\index.html", eccLevel);
            QRCodeData qrCodeData = qrGenerator.CreateQrCode(url.ToString(), eccLevel);
            QRCode qrCode = new QRCode(qrCodeData);
            Bitmap qrCodeBitmap = qrCode.GetGraphic(20, "#000000", "#ffffff");

            ImageSource qrImageSource =ConvertBitmapToBitmapImage(qrCodeBitmap);
            imgQrCode.Source = qrImageSource;
        }
 protected void btnGenerate_Click(object sender, EventArgs e)
 {
     string code = this.txtCode.Text;
     QRCodeGenerator qrGenerator = new QRCodeGenerator();
     QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
     System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
     imgBarCode.Height = 150;
     imgBarCode.Width = 150;
     using (Bitmap bitMap = qrCode.GetGraphic(20))
     {
         using (MemoryStream ms = new MemoryStream())
         {
             bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
             byte[] byteImage = ms.ToArray();
             imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
             imgUrl = imgBarCode.ImageUrl;
         }
         plBarCode.Controls.Add(imgBarCode);
         Image1.ImageUrl = imgUrl;
         Image1.Visible = true;
     }
 }
Пример #6
0
        public IActionResult Post(string postId)
        {
            var instanceMain = _repos.GetSingleDataById(postId);
            var instanceSend = new PostViewModel()
            {
                ID                      = instanceMain.ID,
                ContentHtml             = instanceMain.ContentHtml,
                ContentInBrief          = instanceMain.ContentInBrief,
                Title                   = instanceMain.Title,
                PostPictureName         = instanceMain.PostPictureName,
                LastModifiedDateAndTime = instanceMain.LastModifiedDateAndTime
            };

            instanceSend.Barcode = GetPostBrcode();
            return(View(instanceSend));

            Byte[] GetPostBrcode()
            {
                QRCodeGenerator qrGenerator = new QRCodeGenerator();

                ViewData["Url"] = Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(Request);
                QRCodeData qrCodeData = qrGenerator.CreateQrCode(ViewData["Url"].ToString(),
                                                                 QRCodeGenerator.ECCLevel.Q);
                QRCode qrCode      = new QRCode(qrCodeData);
                Bitmap qrCodeImage = qrCode.GetGraphic(20);

                return(GetImageBytesByBitmap(qrCodeImage));

                Byte[] GetImageBytesByBitmap(Bitmap img)
                {
                    using (MemoryStream stream = new MemoryStream())
                    {
                        img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                        return(stream.ToArray());
                    }
                }
            }
        }
Пример #7
0
        public ActionResult Index()
        {
            try
            {
                int    userid = HomeController.UserId;   //Get userid of logged in user
                string room   = Request.Query["roomid"]; //Get roomid from url parameter

                var request = HttpContext.Request;
                using (MemoryStream ms = new MemoryStream()) //QR-code generation
                {
                    QRCodeGenerator qrGenerator = new QRCodeGenerator();

                    QRCodeData qrCodeData = qrGenerator.CreateQrCode("https://145.24.222.130" + request.Path + "?RoomId=" + room, QRCodeGenerator.ECCLevel.Q);
                    QRCode     qrCode     = new QRCode(qrCodeData);


                    using (Bitmap qrCodeImage = qrCode.GetGraphic(20))
                    {
                        qrCodeImage.Save(ms, ImageFormat.Png);
                        ViewBag.QRCodeImage = "data:image/png;base64," + Convert.ToBase64String(ms.ToArray());
                    }
                }

                Database        db      = new Database();                       // Make instance of database class
                List <string[]> results = db.getReservations(room);             // Get reservation from database object and store returned values in List of string []'s
                var             json    = JsonConvert.SerializeObject(results); //Convert previous list of string []'s to json object
                ViewData["results"] = json;                                     //Hands over json object to view

                return(View());                                                 //View gets returned with viewdata
            }
            catch (Exception e)                                                 //Exception catcher
            {
                Debug.WriteLine("Index Schedule Exception: {0}", e);
                return(RedirectToAction("Error", "Home"));

                throw;
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = familydata1.id;

            Label1.Text = "Family ID:" + id.ToString();
            string sql  = "select f.Name,f.Gender,f.Address,f.Relationship,f.DOB,f.marital_status,f.Education,f.Occupation,f.father_spouse,f.Religion from family f where f.ID = '" + id + "'";
            string sql1 = "select f1.Name,f1.Gender,f1.Address,f1.Relationship,f1.DOB,f1.marital_status,f1.Education,f1.Occupation,f1.father_spouse,f1.Religion from family1 f1 where f1.ID = '" + id + "'";

            con.Open();
            SqlDataAdapter da  = new SqlDataAdapter(sql, con);
            SqlDataAdapter da1 = new SqlDataAdapter(sql1, con);
            DataTable      dt  = new DataTable();
            DataTable      dt1 = new DataTable();

            da.Fill(dt);
            da1.Fill(dt1);
            GridView1.DataSource = dt;
            GridView2.DataSource = dt1;
            GridView1.DataBind();
            GridView2.DataBind();
            con.Close();
            string          code        = Label1.Text.Trim();
            QRCodeGenerator qrGenerator = new QRCodeGenerator();

            QRCodeGenerator.QRCode          qrCode    = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
            System.Web.UI.WebControls.Image imgBarCod = new System.Web.UI.WebControls.Image();
            Image3.Height = 100;
            Image3.Width  = 100;
            using (Bitmap bitMap = qrCode.GetGraphic(20))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    byte[] byteImage = ms.ToArray();
                    Image3.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
                }
            }
        }
Пример #9
0
        private void GenerateQRFromText(string text)
        {
            try
            {
                // Creating the elements here
                QRCodeGenerator qrGenerator = new QRCodeGenerator();
                QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
                QRCode          qrCode      = new QRCode(qrCodeData);
                Bitmap          qrCodeImage = qrCode.GetGraphic(20);

                // If user checks the check box saves the image with default name
                if (save_image_text == true)
                {
                    using (FolderBrowserDialog f = new FolderBrowserDialog())
                    {
                        if (f.ShowDialog() == DialogResult.OK)
                        {
                            qrCodeImage.Save(Path.Combine(f.SelectedPath, "qr-code-text.png"));
                        }
                    }
                }

                // show image
                pictureBoxText.Image = qrCodeImage;

                // free ram
                qrGenerator.Dispose();
                qrCodeData.Dispose();
                qrCode.Dispose();
            }
            //If ex is catched displat
            //TODO : Custom Mess
            // Not more showing the message but an fix for this error
            catch (Exception e)
            {
                MetroSetMessageBox.Show(this, "An error : " + e.Message, "QR Creator");
            }
        }
Пример #10
0
        private async Task GnerateQrCode()
        {
            PicBoxQRCode.SuspendLayout();
            Image qrCodeImg = null;

            await Task.Run(() =>
            {
                var qrCodeGenerator   = new QRCodeGenerator();
                string enValue        = _activeSettings.QR_CodeLevel.ToString();
                var ecc               = (QRCodeGenerator.ECCLevel)Enum.Parse(typeof(QRCodeGenerator.ECCLevel), enValue);
                string encoderContent = CreateWifimetadataFormatString(txtSSId.Text, rdWPA.Checked, txtGeneratedPassword.Text, rdSSIDVisibleFalse.Checked);
                var qrCode            = qrCodeGenerator.CreateQrCode(encoderContent, ecc);
                int moduleCount       = qrCode.ModuleMatrix.Count;

                int optimalPixelsPerMatrixModule = moduleCount;
                if (_qrOutputSize == null)
                {
                    _qrOutputSize = new Size(_activeSettings.ImageWidth, _activeSettings.ImageWidth);
                }
                else if (_qrOutputSize.Width < _activeSettings.ImageWidth || _qrOutputSize.Height < _activeSettings.ImageWidth)
                {
                    _qrOutputSize = new Size(_activeSettings.ImageWidth, _activeSettings.ImageWidth);
                }

                double pixelsDelta           = _qrOutputSize.Width;
                optimalPixelsPerMatrixModule = Convert.ToInt32(Math.Ceiling(pixelsDelta / Convert.ToDouble(moduleCount)));


                qrCodeImg = qrCode.CreateBitmap(optimalPixelsPerMatrixModule);
            });


            PicBoxQRCode.Image = qrCodeImg;
            PicBoxQRCode.ResumeLayout();
            PicBoxQRCode.Refresh();
            PicBoxQRCode.BorderStyle = BorderStyle.FixedSingle;
            PicBoxQRCode.SizeMode    = PictureBoxSizeMode.Zoom;
        }
Пример #11
0
        private void CreateBody(int participantId, Camp regCamp, RegistrationType regType)
        {
            pageBody  = "<p><b>" + txtCharacterName.Text + "</b>,</p>";
            pageBody += "<p>Thank you for registering to attend <b>Ragnarok XXXIV</b>";
            if (regType.IsMerchant)
            {
                pageBody += " as a merchant";
            }
            pageBody += "!</p>";

            if (regCamp.Id != 0)
            {
                pageBody += "<p>You are marked down as an attendee staying in <b>" + regCamp.CampName + "</b>. If your camp changes, please contact ";
                pageBody += "<a href=\"mailto:[email protected]\">[email protected]</a> to change your camp, or you can change it ";
                pageBody += "when you arrive at Ragnarok.</p>";
            }
            else
            {
                pageBody += "<p>You are marked down as not having a camp selected yet. If you choose a camp, please contact ";
                pageBody += "<a href=\"mailto:[email protected]\">[email protected]</a> to select your camp, or you can select your ";
                pageBody += "camp when you arrive at Ragnarok.</p>";
            }

            pageBody += "<p>Your selected arrival date is <b>" + regType.ArrivalDate.ToString("MM/dd/yyyy") + "</b>.</p>";

            QRCodeGenerator  qrGenerator = new QRCodeGenerator();
            QRCodeData       qrCodeData  = qrGenerator.CreateQrCode("http://dagorhirragnarok.com/CheckIn.aspx?pid=" + participantId, QRCodeGenerator.ECCLevel.Q);
            BitmapByteQRCode qrCode      = new BitmapByteQRCode(qrCodeData);

            qrCodeBytes = qrCode.GetGraphic(20);

            string imgSource = "data:image/png;base64," + Convert.ToBase64String(qrCodeBytes, Base64FormattingOptions.None);

            pageBody += "<p>For expedited check-in at Troll when you arrive at Ragnarok, please present this QR Code to the Troll staff:</p>";
            pageBody += "<center><p><img style=\"height: 300px; width: 300px;\" src=\"" + imgSource + "\" /></p></center>";
            pageBody += "<p>We look forward to seeing you at Ragnarok!</p>";
            pageBody += "<p>----------------------------------------------<br />Troll</p>";
        }
Пример #12
0
        /// <summary>
        /// 创建二维码返回文件路径名称
        /// </summary>
        /// <param name="plainText">二维码内容</param>
        public static string CreateQRCodeToFile(string plainText)
        {
            try
            {
                string fileName = "";
                if (String.IsNullOrEmpty(plainText))
                {
                    return("");
                }

                //二维码文件目录
                string filePath = System.Web.HttpContext.Current.Server.MapPath("~/") + "QRCoder\\";

                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                }
                string name = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(100, 1000) + ".jpeg";
                //创建二维码文件路径名称
                fileName = filePath + name;

                QRCodeGenerator qrGenerator = new QRCodeGenerator();
                //QRCodeGenerator.ECCLevel:纠错能力,Q级:约可纠错25%的数据码字
                QRCodeData qrCodeData  = qrGenerator.CreateQrCode(plainText, QRCodeGenerator.ECCLevel.Q);
                QRCode     qrcode      = new QRCode(qrCodeData);
                Bitmap     qrCodeImage = qrcode.GetGraphic(15);
                qrCodeImage.Save(fileName, ImageFormat.Jpeg);

                //生成 http绝对路径
                string relativeUrl = ConfigurationManager.AppSettings["ImageQRCode"].ToString();
                string httpPath    = relativeUrl + name;
                return(httpPath);
            }
            catch (Exception ex)
            {
                throw new Exception("创建二维码返回文件路径名称方法异常", ex);
            }
        }
        public ActionResult GenerateQR(info INFO)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode("Name: " + INFO.Name + " Phone No: " + INFO.Phone + " Email: " + "" + INFO.Email, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);
            Bitmap          qrCodeImage = qrCode.GetGraphic(20);
            string          path1       = Guid.NewGuid() + "qrcode.png";
            string          path        = Server.MapPath("~/Images/" + path1);

            try
            {
                qrCodeImage.Save(path);
            }
            catch (Exception e)
            {
            }

            string ImgUrl = "Images/" + path1;

            ViewBag.imgS = ImgUrl;

            return(Json(new { img = ImgUrl }, JsonRequestBehavior.AllowGet));
        }
        private void button2_Click(object sender, EventArgs e)
        {
            Top3FRM tp = new Top3FRM();

            conversion  = DGVehiculos.CurrentRow.Cells[2].Value.ToString();
            conversion1 = DGVehiculos.CurrentRow.Cells[3].Value.ToString();
            conversion2 = DGVehiculos.CurrentRow.Cells[4].Value.ToString();
            conversion3 = DGVehiculos.CurrentRow.Cells[5].Value.ToString();
            conversion4 = DGVehiculos.CurrentRow.Cells[6].Value.ToString();
            conversion5 = DGVehiculos.CurrentRow.Cells[7].Value.ToString();
            //conversion4 = dg

            texToQr.Text = $"{conversion}\r\n{conversion1}\r\n{conversion2}\r\n{conversion3}\r\n{conversion4}\r\n{conversion5}\r\n{conversion6}";
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(texToQr.Text, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);
            CodigoQRFRM     code        = new CodigoQRFRM();

            code.Show();
            code.pk1.Image = qrCode.GetGraphic(5);

            this.Close();
        }
Пример #15
0
    protected void btnGenerate_OnClick(object sender, EventArgs e)
    {
        string          Code        = txtCode.Text;
        QRCodeGenerator qrGenerator = new QRCodeGenerator();

        QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(Code, QRCodeGenerator.ECCLevel.Q);

        Image imgQrCode = new Image();

        imgQrCode.Height = 150;
        imgQrCode.Width  = 150;

        using (Bitmap bitmap = qrCode.GetGraphic(20))
        {
            using (MemoryStream ms = new MemoryStream())
            {
                bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] byteImage = ms.ToArray();
                imgQrCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
            }
            PHQRCode.Controls.Add(imgQrCode);
        }
    }
Пример #16
0
        private void SaveQrImage(Asset asset)
        {
            var assetQrDto = new AssetQrDto();

            assetQrDto.Id   = asset.Id;
            assetQrDto.Code = asset.Code;

            var content   = JsonConvert.SerializeObject(assetQrDto);
            var generator = new QRCodeGenerator();
            var codeData  = generator.CreateQrCode(content, QRCodeGenerator.ECCLevel.M, true);
            var qrCode    = new QRCode(codeData);

            var qrImage = qrCode.GetGraphic(10, Color.Black, Color.White, false);

            var savePath = $"{Directory.GetCurrentDirectory()}//wwwroot//upload//QrCodes";

            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            savePath += $"//{asset.Id}.jpg";
            qrImage.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
Пример #17
0
        private static void RysowankiKolorek()
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            int             i           = 0;

            foreach (int version in new int[] { 7 })
            {
                QRCodeData qrCodeData = qrGenerator.CreateQrCode(
                    "Taki kawałek wystarcza 👨‍🏭",
                    QRCodeGenerator.ECCLevel.L,
                    requestedVersion: version);;

                QRCode qrc = new QRCode(qrCodeData);


                var b = qrc.GetGraphic(
                    new int[] { 20, 20, 7, 7, 5, 5 }[i++],
                    //new ColorProviderDebug(),
                    new ColorProviders.ColorProviderBW(),
                    drawQuietZones: false, drawThinLines: true);
                b.Save(String.Format("RysowankiKolorek{0:00}.png", version));
            }
        }
        private void Initialize()
        {
            InitializeComponent();
            this.listBox1.SelectedIndexChanged += ListBox1_SelectedIndexChanged;
            SetUpConnection();
            cnn.Open();
            messages = GetEmails();
            if (!this.safe)
            {
                qrList = new List <Bitmap>();
                for (int i = 0; i < messages.Count; i++)
                {
                    QRCodeGenerator qrGenerator = new QRCodeGenerator();
                    QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(messages[i][0], QRCodeGenerator.ECCLevel.Q);
                    QRCode          qrCode      = new QRCode(qrCodeData);
                    Bitmap          qrCodeImage = qrCode.GetGraphic(20);
                    qrList.Add(qrCodeImage);

                    Petition(i);
                }
            }
            FillList();
        }
Пример #19
0
        public static string GetPTQRCode(string url, int pixel, string logoPath = null)
        {
            QRCodeGenerator generator = new QRCodeGenerator();

            // QRCodeGenerator.ECCLevel:纠错能力
            QRCodeData codeData = generator.CreateQrCode(url, QRCodeGenerator.ECCLevel.M, true);
            QRCode     qrcode   = new QRCode(codeData);
            Bitmap     logoIcon = logoPath == null ? null : new Bitmap(logoPath);

            // pixelsPerModule  // 生成二维码图片的像素大小
            // darkColor        // 暗色   一般设置为Color.Black
            // lightColor       // 亮色   一般设置为Color.White
            // icon             // 二维码 水印图标 例如:Bitmap icon = new Bitmap(context.Server.MapPath("~/images/zs.png")); 默认为NULL ,加上这个二维码中间会显示一个图标
            // iconSizePercent  // 水印图标的大小比例 ,可根据自己的喜好设置
            // iconBorderWidth  // 水印图标的边框
            // drawQuietZones   // 静止区,位于二维码某一边的空白边界,用来阻止读者获取与正在浏览的二维码无关的信息 即是否绘画二维码的空白边框区域 默认为true
            Bitmap qrImage = qrcode.GetGraphic(pixel, Color.Black, Color.White, icon: logoIcon, drawQuietZones: true);

            MemoryStream ms = new MemoryStream();

            qrImage.Save(ms, ImageFormat.Jpeg);
            return(Convert.ToBase64String(ms.ToArray()));
        }
Пример #20
0
        public static string GenerateQrCodeImage(string qrCodeFileName, string qrCodeContent)
        {
            string rootResourceDir = Path.Combine(Directory.GetCurrentDirectory(), "Resources");
            string qrCodeDir       = Path.Combine(rootResourceDir, "QRCodes");
            string qrCodeFilePath  = Path.Combine(qrCodeDir, qrCodeFileName);
            string qrCodeFileUrl   = BaseURIs.STATIC_RESOURCES + qrCodeFilePath.Replace(rootResourceDir, "").Replace("\\", "/");

            if (!Directory.Exists(qrCodeDir))
            {
                Directory.CreateDirectory(qrCodeDir);
            }

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(qrCodeContent, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);

            using (Bitmap qrCodeImage = qrCode.GetGraphic(20))
            {
                qrCodeImage.Save(qrCodeFilePath, ImageFormat.Png);
            }

            return(qrCodeFileUrl);
        }
Пример #21
0
        public Bitmap GenerateQRCodeBmp(string content, bool customSize = true)
        {
            int width = 200, height = 200;

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData = qrGenerator.CreateQrCode(content, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode = new QRCode(qrCodeData);
            Bitmap          qrCodeImage = qrCode.GetGraphic(20);

            if (customSize)
            {
                Bitmap qrcodebitmap = new Bitmap(width, height);
                //RectangleF rectSerial = new RectangleF(0, 0, width, height);

                Graphics g = Graphics.FromImage(qrcodebitmap);
                g.DrawImage(qrCodeImage, 0, 0, width, height);
                return(qrcodebitmap);
            }
            else
            {
                return(qrCodeImage);
            }
        }
        public void InsertQrCodePurchaseInfo(int userId, int productId)
        {
            var    product      = productRepository.Read(productId);
            var    user         = userRepository.Read(userId);
            string purchaseInfo = $"At {DateTime.Now.ToShortTimeString()} {user.UserName} " +
                                  $"purchased {product.ProductName}";

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(purchaseInfo, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);
            Bitmap          qrCodeImage = qrCode.GetGraphic(20);

            using (MemoryStream ms = new MemoryStream())
            {
                qrCodeImage.Save(ms, ImageFormat.Png);
                qrCodeRepository.Insert(new QrCodeEntity()
                {
                    UserId     = userId,
                    QrCodeType = QrCodeType.TextEncodedQrCode,
                    Content    = ms.ToArray()
                });
            }
        }
Пример #23
0
        private List <QRContainer> generateQR()
        {
            QRCodeGenerator    qrGenerator  = new QRCodeGenerator();
            List <QRContainer> qRContainers = new List <QRContainer>();

            //qr generation loop
            for (int i = STARTING_POINT; i < STARTING_POINT + QUANTITY; i++)
            {
                string       code        = this.GenerateCode(i); // reuse the preview function
                QRCodeData   qrCodeData  = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
                QRCode       qrCode      = new QRCode(qrCodeData);
                Bitmap       qrCodeImage = qrCode.GetGraphic(PIXELS_PER_MODULE);
                MemoryStream strm        = new MemoryStream();
                qrCodeImage.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
                qRContainers.Add(new QRContainer
                {
                    code   = code,
                    bitmap = XImage.FromStream(strm)
                });
            }

            return(qRContainers);
        }
Пример #24
0
        public static async Task <BitmapImage> GetQrCode(string SourceText, string Ecc)
        {
            var level       = Ecc;
            var eccLevel    = (QRCodeGenerator.ECCLevel)(level == "L" ? 0 : level == "M" ? 1 : level == "Q" ? 2 : 3);
            var qrGenerator = new QRCodeGenerator();
            var qrCodeData  = qrGenerator.CreateQrCode(SourceText, eccLevel);
            var qrCode      = new BitmapByteQRCode(qrCodeData);
            var qrCodeImage = qrCode.GetGraphic(20);

            using (var stream = new InMemoryRandomAccessStream())
            {
                using (var writer = new DataWriter(stream.GetOutputStreamAt(0)))
                {
                    writer.WriteBytes(qrCodeImage);
                    await writer.StoreAsync();
                }
                BitmapImage bit = new BitmapImage();
                await bit.SetSourceAsync(stream);

                BitmapImage Bitmap = bit;
                return(Bitmap);
            }
        }
Пример #25
0
        public void Gener(string text)
        {
            //QRCodeGenerator qrGenerator = new QRCodeGenerator();
            //QRCodeData qrCodeData = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.M);
            //QRCode qrCode = new QRCode(qrCodeData);
            //Bitmap qrCodeImage = qrCode.GetGraphic(8, Color.Black, Color.White, icon: ((Bitmap)Bitmap.FromFile(Server.MapPath("~/logo.jpg"))));

            QRCoder.PayloadGenerator.OneTimePassword generator = new QRCoder.PayloadGenerator.OneTimePassword()
            {
                Secret = "pwq6 5q55",
                Issuer = "Google",
                Label  = "*****@*****.**",
            };
            string payload = generator.ToString();

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);
            var             qrCodeImage = qrCode.GetGraphic(8);

            Response.ClearContent();
            qrCodeImage.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);;
        }
Пример #26
0
        public static void  GenerateSave(string guid, string value)
        {
            Guid path = Guid.NewGuid();

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(value, QRCodeGenerator.ECCLevel.Q);
            Base64QRCode    qrCode      = new Base64QRCode(qrCodeData);
            string          fpath       = Path.Combine(HostingEnvironment.MapPath("~/Content/QR"), guid + ".png");

            string qrCodeImage = qrCode.GetGraphic(20);

            if (File.Exists(fpath))
            {
                File.Delete(fpath);
            }
            File.WriteAllBytes(fpath, Convert.FromBase64String(qrCodeImage));
            // byte[] data = Convert.FromBase64String(qrCodeImage);
            //using (Image image = Image.FromStream(new MemoryStream(data, 0, data.Length)))
            // {

            //    image.Save(fpath, ImageFormat.Png);  // Or Png
            //   }
        }
Пример #27
0
    protected void lnkGenerateQRCode_Click(object sender, EventArgs e)
    {
        LinkButton lnk  = sender as LinkButton;
        string     data = "BA50D346-71E3-4146-8356-484685C98C39";// lnk.CommandArgument; // heleleik static qoyduq

        QRCodeGenerator qrGenerator = new QRCodeGenerator();
        QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
        QRCode          qrCode      = new QRCode(qrCodeData);
        Bitmap          qrCodeImage = qrCode.GetGraphic(20);

        Response.Clear();
        Response.BufferOutput = false;
        string fileName = $"{data}.jpg";

        Response.ContentType = "application/jpeg";
        Response.AddHeader("content-disposition", $"attachment; filename={fileName}");

        using (MemoryStream stream = new MemoryStream())
        {
            qrCodeImage.Save(Response.OutputStream, ImageFormat.Jpeg);
        }
        Response.End();
    }
Пример #28
0
        public bool GenerarQR(String RFCEmisor, String RFCReceptor, String Total)
        {
            bool Resultado = false;

            QRTexto = "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx?&" + "id=" + UUID + "&fe=" + SelloCFD.Substring(SelloCFD.Length - 8, 8) + "&re=" + RFCEmisor + "&rr=" + RFCReceptor + "&tt=" + Total;

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(QRTexto, QRCodeGenerator.ECCLevel.M);
            QRCode          qrCode      = new QRCode(qrCodeData);

            System.IO.MemoryStream mem = new System.IO.MemoryStream();
            EncoderParameters      encoderParameters = new EncoderParameters(1);

            encoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 75L);
            qrCode.GetGraphic(20).Save(mem, GetEncoder(ImageFormat.Jpeg), encoderParameters);
            QR        = mem.ToArray();
            Resultado = true;
            mem.Close();
            mem.Dispose();
            qrCode.Dispose();
            GC.WaitForFullGCComplete();
            return(Resultado);
        }
Пример #29
0
        /// <summary>
        /// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
        /// </summary>
        /// <param name="values">The array of values that the source bindings in the <see cref="MultiBinding"/> produces. The value <see cref="System.Windows.DependencyProperty.UnsetValue"/> indicates that the source binding has no value to provide for conversion.</param>
        /// <param name="targetType">The type of the binding target property</param>
        /// <param name="parameter">The converter parameter to use</param>
        /// <param name="culture">The culture to use in the converter</param>
        /// <returns>
        /// A converted value.
        /// If the method returns <c>null</c>, the valid null value is used.
        /// A return value of <see cref="System.Windows.DependencyProperty.UnsetValue"/> indicates that the converter did not produce a value, and that the binding will use the <see cref="BindingBase.FallbackValue"/> if it is available, or else will use the default value.
        /// A return value of <see cref="Binding.DoNothing"/> indicates that the binding does not transfer the value or use the <see cref="BindingBase.FallbackValue"/> or the default value.
        /// </returns>
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                var secret   = values[0] as string;
                var user     = values[1] as UserInfo;
                var instance = values[2] as Instance;
                var otp_uri  = String.Format(user.ID != null ? "otpauth://totp/{1}:{2}?secret={0}&issuer={3}" : "otpauth://totp/{1}?secret={0}&issuer={3}",
                                             secret,
                                             instance.Base.Host,
                                             user.ID,
                                             HttpUtility.UrlEncode(instance.ToString()));

                var qr_generator = new QRCodeGenerator();
                var qr_code_data = qr_generator.CreateQrCode(otp_uri, QRCodeGenerator.ECCLevel.Q);
                var qr_code      = new XamlQRCode(qr_code_data);
                return(qr_code.GetGraphic(3, true));
            }
            catch { }

            // Fallback to blank image.
            return(new Uri("pack://application:,,,/eduVPN.Views;component/Resources/Blank.png"));
        }
Пример #30
0
        private void RenderQrCode()
        {
            string level = comboBoxECC.SelectedItem.ToString();

            QRCodeGenerator.ECCLevel eccLevel = (QRCodeGenerator.ECCLevel)(level == "L" ? 0 : level == "M" ? 1 : level == "Q" ? 2 : 3);
            using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
            {
                using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(textBoxQRCode.Text, eccLevel))
                {
                    using (QRCode qrCode = new QRCode(qrCodeData))
                    {
                        pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White,
                                                                             GetIconBitmap(), (int)iconSize.Value);

                        this.pictureBoxQRCode.Size = new System.Drawing.Size(pictureBoxQRCode.Width, pictureBoxQRCode.Height);
                        //Set the SizeMode to center the image.
                        this.pictureBoxQRCode.SizeMode = PictureBoxSizeMode.CenterImage;

                        pictureBoxQRCode.SizeMode = PictureBoxSizeMode.StretchImage;
                    }
                }
            }
        }
Пример #31
0
        private void RenderQrCode(string _QRname, string _qr)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();

            QRCodeData qrCodeData = qrGenerator.CreateQrCode(_qr, QRCodeGenerator.ECCLevel.Q);

            QRCode qrCode = new QRCode(qrCodeData);

            string filePath = @"C:\Users\Public\Pictures\" + _QRname.Replace("|", "").ToString().Trim() + ".png";

            Bitmap bitMap = qrCode.GetGraphic(20);

            System.Windows.Controls.Image imgBarCode = new System.Windows.Controls.Image();
            imgBarCode.Height = 150;
            imgBarCode.Width  = 150;

            using (MemoryStream ms = new MemoryStream())
            {
                bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] byteImage = ms.ToArray();
                bitMap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Пример #32
0
        // GET: Home/Create
        public ActionResult Register()
        {
            //generate a string like this
            //otpauth://totp/Example:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Example

            //secret that has 16 chars A-Z, not 0, not 1, but 2-7
            string secret  = RandomBase32String(16);
            string otpauth = "otpauth://totp/CoolApplication:someaccount?secret=" +
                             secret + "&issuer=CoolApplication";

            //to generate a QR code
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(otpauth, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);
            Bitmap          qrCodeImage = qrCode.GetGraphic(20);
            ImageConverter  converter   = new ImageConverter();

            ViewBag.QRCode    = (byte[])converter.ConvertTo(qrCodeImage, typeof(byte[]));
            Session["secret"] = secret;


            return(View());
        }
Пример #33
0
        public static string GenerateQRCode(IWebHostEnvironment environment, string message)
        {
            string root     = environment.WebRootPath + "\\qrcode";
            string fileName = Guid.NewGuid().ToString() + ".png";
            string path     = Path.Combine(root, fileName);

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(message, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrCode      = new QRCode(qrCodeData);
            Bitmap          qrCodeImage = qrCode.GetGraphic(20);

            using (MemoryStream memory = new MemoryStream())
            {
                using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
                {
                    qrCodeImage.Save(memory, ImageFormat.Png);
                    byte[] bytes = memory.ToArray();
                    fs.Write(bytes, 0, bytes.Length);
                }
            }

            return(fileName);
        }
        public void QRCodeTerminalAsAscii()
        {
            WechahtyEvent.Subscribe <EventScanPayload>(async(eventData) =>
            {
                if (eventData.Status == ScanStatus.Waiting || eventData.Status == ScanStatus.Timeout)
                {
                    await Task.Run(() =>
                    {
                        string qrcodeImageUrl = GetWechatGithubQrCode(eventData.Qrcode);

                        Url generator  = new Url(qrcodeImageUrl);
                        string payload = generator.ToString();

                        QRCodeGenerator qrGenerator = new QRCodeGenerator();
                        QRCodeData qrCodeData       = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.L);

                        AsciiQRCode qrCodeAsi   = new AsciiQRCode(qrCodeData);
                        string qrCodeAsAsciiArt = qrCodeAsi.GetGraphic(1);
                        Console.WriteLine(qrCodeAsAsciiArt);
                    });
                }
            });
        }
        public static void GenQRCode(String message, String Code)
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            Cloudinary      _cloudinary = new Cloudinary(new Account("dpciaiobf", "546941639243358", "-clBvD99twwKZUYzhb2eLQDt7SU"));

            QRCodeData qrCodeData  = qrGenerator.CreateQrCode(message, QRCodeGenerator.ECCLevel.Q);
            QRCode     qrCode      = new QRCode(qrCodeData);
            Bitmap     qrCodeImage = qrCode.GetGraphic(20);

            System.IO.MemoryStream stream = new MemoryStream();
            qrCodeImage.Save(stream, ImageFormat.Png);

            var bytes = ((MemoryStream)stream).ToArray();

            System.IO.Stream  inputStream = new MemoryStream(bytes);
            ImageUploadParams a           = new ImageUploadParams
            {
                File     = new FileDescription(Guid.NewGuid().ToString(), inputStream),
                PublicId = Code
            };

            _cloudinary.Upload(a);
        }
Пример #36
0
 private static void GenerateQRCode(string payloadString, QRCodeGenerator.ECCLevel eccLevel, string outputFileName, ImageFormat imgFormat)
 {
     using (var generator = new QRCodeGenerator())
     {
         using (var data = generator.CreateQrCode(payloadString, eccLevel))
         {
             using (var code = new QRCode(data))
             {
                 using (var bitmap = code.GetGraphic(20))
                 {
                     bitmap.Save(outputFileName, imgFormat);
                 }
             }
         }
     }
 }
Пример #37
0
        private void renderQRCode()
        {
            string level = comboBox1.SelectedItem.ToString();
            QRCodeGenerator.ECCLevel eccLevel = (QRCodeGenerator.ECCLevel)(level == "L" ? 0 : level == "M" ? 1 : level == "Q" ? 2 : 3);
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData qrCodeData = qrGenerator.CreateQrCode(textBoxQRCode.Text, eccLevel);
            QRCode qrCode = new QRCode(qrCodeData);

            pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White, getIconBitmap());

            //Image card = qrCode.GetGraphic(20, Color.Black, Color.White, getIconBitmap());

            //using (FileStream fs = new FileStream(@"D:\图片\58.png", FileMode.OpenOrCreate, FileAccess.Write))
            //{
            //    card.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
            //    fs.Close();
            //}
        }
Пример #38
0
        private void RenderQrCode()
        {
            string level = comboBoxECC.SelectedItem.ToString();
            QRCodeGenerator.ECCLevel eccLevel = (QRCodeGenerator.ECCLevel)(level == "L" ? 0 : level == "M" ? 1 : level == "Q" ? 2 : 3);
            using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
            {
                using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(textBoxQRCode.Text, eccLevel))
                {
                    using (QRCode qrCode = new QRCode(qrCodeData))
                    {

                        pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White,
                            GetIconBitmap(), (int) iconSize.Value);

                         this.pictureBoxQRCode.Size = new System.Drawing.Size(pictureBoxQRCode.Width, pictureBoxQRCode.Height);
                        //Set the SizeMode to center the image.
                        this.pictureBoxQRCode.SizeMode = PictureBoxSizeMode.CenterImage;

                        pictureBoxQRCode.SizeMode = PictureBoxSizeMode.StretchImage;
                    }
                }
            }
        }
Пример #39
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("No source file location parameter provided.");
            }
            else
            {
                try
                {
                    string sourceFile = args[0];
                    Console.WriteLine("Source file: " + args[0]);

                    TextFieldParser parser = new TextFieldParser(sourceFile);
                    parser.HasFieldsEnclosedInQuotes = true;
                    parser.SetDelimiters(",");

                    // Get headers
                    string[] headerArray = parser.ReadFields();

                    // Get contents
                    List<string[]> rowList = new List<string[]>();
                    while (!parser.EndOfData)
                    {
                        rowList.Add(parser.ReadFields());
                    }

                    Parallel.ForEach(rowList, (row) =>
                    {
                        try
                        {
                            string line = "";

                            for (int i = 0; i < row.Length; i++)
                            {
                                line += String.Format("{0}: {1}\n", headerArray[i], row[i]).ToUpper();
                            }

                            Console.Write(line);

                            // Create identifier
                            string identifier = String.Format("{0}, {1} {2}", row[2], row[0], row[1]).ToUpper().Replace("N/A", String.Empty);

                            // Generate qr code image
                            QRCodeGenerator qrGenerator = new QRCodeGenerator();
                            QRCodeData qrCodeData = qrGenerator.CreateQrCode(line, QRCodeGenerator.ECCLevel.Q);
                            QRCode qrCode = new QRCode(qrCodeData);
                            Bitmap qrCodeImage = qrCode.GetGraphic(20);

                            Directory.CreateDirectory("output");

                            // Save image to file
                            qrCodeImage.Save(String.Format("output\\{0}.jpg", identifier));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }      
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }                           
            }

            Console.Write("Press any key to continue...");
            Console.ReadKey();
        }
Пример #40
0
 private static Bitmap CreateQrBitmap(string content)
 {
     QRCodeGenerator.ECCLevel eccLevel = QRCodeGenerator.ECCLevel.Q;
     QRCodeGenerator qrGenerator = new QRCodeGenerator();
     QRCodeData qrCodeData = qrGenerator.CreateQrCode(content, eccLevel);
     QRCode qrCode = new QRCode(qrCodeData);
     Bitmap bitmap = qrCode.GetGraphic(20);
     return bitmap;
 }
Пример #41
0
 private void LoadValues()
 {
     DataTable dt = new DataTable();
     dt = (DataTable)Session["dt"];
     username.Text = dt.Rows[0]["Username"].ToString();
     code = dt.Rows[0]["Random_No"].ToString();
     Session["code"] = code;
     QRCodeGenerator qrGenerator = new QRCodeGenerator();
     QRCodeGenerator.QRCode qrCode = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.H);
     System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
     imgBarCode.Height = 150;
     imgBarCode.Width = 150;
     using (Bitmap bitMap = qrCode.GetGraphic(20))
     {
         using (MemoryStream ms = new MemoryStream())
         {
             bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
             byte[] byteImage = ms.ToArray();
             imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
         }
         plBarCode.Controls.Add(imgBarCode);
     }
 }
Пример #42
0
        private void MontaPagina(Document document, TNFe nfe, TProtNFe protocolo, string cscId, string cscToken, bool mostrarDetalhesVenda, string via = "")
        {
            var page = document.AddSection();

            // 2.3.1 Divisão I - Informações do Cabeçalho
            var table = page.AddTable();
            table.Rows.LeftIndent = 0;

            // Before you can add a row, you must define the columns
            var column = table.AddColumn("4cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            column = table.AddColumn("6cm");
            //column.Format.Alignment = ParagraphAlignment.Left;

            column = table.AddColumn("6cm");
            //column.Format.Alignment = ParagraphAlignment.Left;

            // Logo NFC-e (opcional)
            // Logo do Contribuinte (opcional)
            var row = table.AddRow();
            row.Cells[0].MergeDown = 2;
            var file = @"..\..\..\NFCerta.NFe\Resources\logo.jpg";
            var image = row.Cells[0].AddImage(file);
            image.Height = "1.3cm";

            // Razão social do Emitente
            row.Cells[1].AddParagraph(nfe.infNFe.emit.xNome);

            // Inscrição Municipal do Emitente (se houver)
            if (nfe.infNFe.emit.IM.HasValue())
            {
                row.Cells[2].AddParagraph("Inscrição Municipal - " + nfe.infNFe.emit.IM);
            }

            row = table.AddRow();

            // CNPJ do Emitente
            row.Cells[1].AddParagraph("CNPJ - " + nfe.infNFe.emit.Item);

            // Inscrição Estadual do Emitente
            row.Cells[2].AddParagraph("Inscrição Estadual - " + nfe.infNFe.emit.IE);

            row = table.AddRow();

            // Endereço Completo do Emitente 
            // Endereço Completo (Logradouro, n, bairro, municipio, sigla, uf)
            row.Cells[1].AddParagraph(nfe.infNFe.emit.enderEmit.xLgr + ", "
                                    + nfe.infNFe.emit.enderEmit.nro + ", "
                                    + nfe.infNFe.emit.enderEmit.xBairro + ", "
                                    + nfe.infNFe.emit.enderEmit.xMun + ", "
                                    + nfe.infNFe.emit.enderEmit.UF.ToString());
            row.Cells[1].MergeRight = 1;

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // 2.3.2 Divisão II – Informações Fixas do DANFE NFC-e
            table = page.AddTable();
            table.Rows.LeftIndent = 0;

            column = table.AddColumn("16cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            row = table.AddRow();
            row.Cells[0].AddParagraph("DANFE NFC-e - Documento Auxiliar de Nota Fiscal de Consumidor Eletrônica");

            row = table.AddRow();
            row.Cells[0].AddParagraph("Não permite aproveitamento de crédito de ICMS");

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // 2.3.3 Divisão III – Informações de Detalhe da Venda
            if (mostrarDetalhesVenda || nfe.infNFe.ide.tpEmis == TipoEmissaoNFe.ContingenciaOffline)
            {
                table = page.AddTable();
                table.Rows.LeftIndent = 0;

                table.AddColumn("2cm");
                table.AddColumn("3cm");
                table.AddColumn("3cm");
                table.AddColumn("2cm");
                table.AddColumn("3cm");
                table.AddColumn("3cm");

                row = table.AddRow();
                row.HeadingFormat = true;
                row.Cells[0].AddParagraph("Código");
                row.Cells[1].AddParagraph("Descrição");
                row.Cells[2].AddParagraph("Qtde");
                row.Cells[3].AddParagraph("Un");
                row.Cells[4].AddParagraph("Valor unit.");
                row.Cells[5].AddParagraph("Valor total");

                foreach (var det in nfe.infNFe.det)
                {
                    row = table.AddRow();
                    row.Cells[0].AddParagraph(det.prod.cProd);
                    row.Cells[1].AddParagraph(det.prod.xProd);
                    row.Cells[2].AddParagraph(det.prod.qCom);
                    row.Cells[3].AddParagraph(det.prod.uCom);
                    row.Cells[4].AddParagraph(det.prod.vUnCom);
                    row.Cells[5].AddParagraph(det.prod.vProd);
                }

                table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);
            }

            // 2.3.4 Divisão IV – Informações de Total do DANFE NFC-e
            table = page.AddTable();
            table.Rows.LeftIndent = 0;
            table.AddColumn("8cm");
            column = table.AddColumn("8cm");
            column.Format.Alignment = ParagraphAlignment.Right;

            // QTD. TOTAL DE ITENS = somatório da quantidade de itens; 
            var qtdTotal = nfe.infNFe.det.Sum(det => float.Parse(det.prod.qCom));
            row = table.AddRow();
            row.Cells[0].AddParagraph("QTD. TOTAL DE ITENS");
            row.Cells[1].AddParagraph(qtdTotal.ToString("0.####"));

            // ACRESCIMO
            row = table.AddRow();
            row.Cells[0].AddParagraph("ACRESCIMO");
            row.Cells[1].AddParagraph(nfe.infNFe.total.ICMSTot.vOutro);

            // VALOR TOTAL = somatório dos valores totais dos itens somados os acréscimos e subtraído dos descontos
            row = table.AddRow();
            row.Cells[0].AddParagraph("VALOR TOTAL R$");
            row.Cells[1].AddParagraph(nfe.infNFe.total.ICMSTot.vNF);

            row = table.AddRow();
            row.Cells[0].AddParagraph("FORMA DE PAGAMENTO");
            // VALOR PAGO = valor pago efetivamente na forma de pagamento identificada imediatamente acima
            row.Cells[1].AddParagraph("Valor Pago");

            // FORMA PAGAMENTO = forma na qual o pagamento da NFC-e foi efetuado (podem ocorrer mais de uma forma de pagamento, devendo neste caso ser indicado o montante parcial do pagamento para a respectiva forma. Exemplo: em dinheiro, em cheque, etc
            nfe.infNFe.pag.ForEach(pag =>
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph(pag.tPag.ToString());
                row.Cells[1].AddParagraph(pag.vPag);
            });

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // 2.3.5 Divisão V – Informações dos Tributos no DANFE NFC-e 
            table = page.AddTable();
            table.Rows.LeftIndent = 0;
            table.AddColumn("8cm");
            column = table.AddColumn("8cm");
            column.Format.Alignment = ParagraphAlignment.Right;
            row = table.AddRow();
            row.Cells[0].AddParagraph("Informação dos TributosTotais Incedentais (Lei Federal 12.741/2012)");
            // Soma de todos os tributos incidentes na operação/prestação, contemplando toda a cadeia de fornecimento
            row.Cells[1].AddParagraph(nfe.infNFe.total.ICMSTot.vTotTrib ?? "0.00");

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // 2.3.6 Divisão Va – Mensagem de Interesse do Contribuinte
            table = page.AddTable();
            table.Rows.LeftIndent = 0;
            column = table.AddColumn("16cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            row = table.AddRow();
            row.Cells[0].AddParagraph(nfe.infNFe.infAdic.infCpl);

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // 2.3.7 Divisão VI – Mensagem Fiscal e Informações da Consulta via Chave de Acesso
            table = page.AddTable();
            table.Rows.LeftIndent = 0;
            column = table.AddColumn("16cm");
            column.Format.Alignment = ParagraphAlignment.Center;

            // Área de Mensagem Fiscal. Quando for o caso deve ser incluídas as seguintes mensagens: “EMITIDA EM CONTINGÊNCIA”, “EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO – SEM VALOR FISCAL”)
            if (nfe.infNFe.ide.tpEmis == TipoEmissaoNFe.ContingenciaOffline)
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph("EMITIDA EM CONTINGÊNCIA");
            }

            if (nfe.infNFe.ide.tpAmb == AmbienteSefaz.Homologacao)
            {
                row = table.AddRow();
                row.Cells[0].AddParagraph("EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO – SEM VALOR FISCAL");
            }

            // Número da NFC-e
            // Série da NFC-e
            // Data e Hora de Emissão da NFC-e (observação: a data de emissão apesar de constar no arquivo XML da NFC-  NFC-e sempre convertida para o horário local)
            var dataEmissaoLocal = nfe.infNFe.ide.dhEmi.FromSefazTime().InZone(nfe.infNFe.emit.enderEmit.UF).ToString("dd/MM/yyyy HH:mm:ss");
            row = table.AddRow();
            var text = "Número {0} Série {1} Emissão {2}".F(nfe.infNFe.ide.nNF, nfe.infNFe.ide.serie, dataEmissaoLocal);
            row.Cells[0].AddParagraph(text + via);
            row = table.AddRow();

            // O texto “Consulte pela Chave de Acesso em” seguido do endereço eletrônico para consulta pública da NFC-e no Portal da Secretaria da Fazenda do Estado do contribuinte
            row.Cells[0].AddParagraph("Consulte pela Chave de Acesso em " + ListaUrl.BuscaUrls(nfe.infNFe.ide.cUF, nfe.infNFe.ide.tpAmb).UrlNfceConsultaChaveAcesso);
            row = table.AddRow();

            // O texto “CHAVE DE ACESSO”, em caixa alta
            row.Cells[0].AddParagraph("CHAVE DE ACESSO");
            row = table.AddRow();

            // A chave de acesso impressa em 11 blocos de quatro dígitos, com um espaço entre cada bloco
            row.Cells[0].AddParagraph(protocolo.infProt.chNFe.SplitChunks(4).JoinString(" "));

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // 2.3.8 Divisão VII – Informações sobre o Consumidor
            table = page.AddTable();
            table.Rows.LeftIndent = 0;
            column = table.AddColumn("16cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            row = table.AddRow();
            row.Cells[0].AddParagraph("CONSUMIDOR");

            if (nfe.infNFe.dest != null)
            {
                var doc = "";

                if (nfe.infNFe.dest.TipoDocumento == TipoDocumento.CNPJ)
                {
                    doc = "CNPJ: ";
                }

                if (nfe.infNFe.dest.TipoDocumento == TipoDocumento.CNPJ)
                {
                    doc = "CPF: ";
                }

                if (nfe.infNFe.dest.TipoDocumento == TipoDocumento.CNPJ)
                {
                    doc = "Id. Estrangeiro: ";
                }

                doc += nfe.infNFe.dest.Item;

                // Nome opcional
                row = table.AddRow();
                row.Cells[0].AddParagraph(doc + " " + nfe.infNFe.dest.xNome);
                row = table.AddRow();

                // Endereco opcional
                row.Cells[0].AddParagraph(nfe.infNFe.emit.enderEmit.xLgr + ", "
                            + nfe.infNFe.emit.enderEmit.nro + ", "
                            + nfe.infNFe.emit.enderEmit.xBairro + ", "
                            + nfe.infNFe.emit.enderEmit.xMun);
            }
            else
            {
                // Na hipótese do não preenchimento das informações de identificação do consumidor na NFCe, deverá ser impressa na área reservada apenas a mensagem “CONSUMIDOR NÃO IDENTIFICADO”.
                row = table.AddRow();
                row.Cells[0].AddParagraph("CONSUMIDOR NÃO IDENTIFICADO");
            }

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // 2.3.9 Divisão VIII – Informações da Consulta via QR Code 
            table = page.AddTable();
            table.Rows.LeftIndent = 0;
            column = table.AddColumn("16cm");
            column.Format.Alignment = ParagraphAlignment.Center;
            row = table.AddRow();

            // O texto “Consulta via leitor de QR Code”
            row.Cells[0].AddParagraph("Consulta via leitor de QR Code");
            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);


            // A imagem do QR Code em tamanho mínimo 25 mm x 25 mm
            var url = nfe.GeraQrCode(cscId, cscToken);
            // "http://www4.fazenda.rj.gov.br/consultaNFCe/QRCode?chNFe=99999999999999999999999999999999999999999999&nVersao=&tpAmp=2&cDest=&dhEmi=323031342D31322D32365430313A31383A33342D30323A3030&vNF=8904.50&vICMS=0.00&digVal=370032007100510061002B0062003000740061006F0051004F003900660041004A007700660064006C005800750071005100760038003D00&cIdToken=cscId&cHashQRCode=1975033D50D8B701C99A2E201E8ED85A75B0D4F4"
            var qrGenerator = new QRCodeGenerator();

            var bitmap = qrGenerator.CreateQrCode(url, QRCodeGenerator.ECCLevel.L).GetGraphic(1);

            var qrFile = new DisposableFile();
            Disposables.Add(qrFile);

            bitmap.Save(qrFile.Path);

            table = page.AddTable();
            table.Rows.LeftIndent = 0;
            column = table.AddColumn("65mm");
            column = table.AddColumn("30mm");
            column = table.AddColumn("65mm");
            row = table.AddRow();

            image = row.Cells[1].AddImage(qrFile.Path);
            image.Height = "30mm";

            table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);

            // No caso de emissão em contingência a informação sobre o protocolo de autorização será suprimida
            if (nfe.infNFe.ide.tpEmis != TipoEmissaoNFe.ContingenciaOffline)
            {
                table = page.AddTable();
                table.Rows.LeftIndent = 0;
                column = table.AddColumn("16cm");
                column.Format.Alignment = ParagraphAlignment.Center;
                row = table.AddRow();
                // O texto “Protocolo de autorização:” com o número do protocolo de autorização obtido para NFC-e e a data e hora da autorização. 
                row.Cells[0].AddParagraph("Protocolo de Autorização: " + protocolo.infProt.nProt + " " +
                                            protocolo.infProt.dhRecbto.FromSefazTime().ToString("dd/MM/yyyy HH:mm:ss"));

                table.SetEdge(0, 0, table.Columns.Count, table.Rows.Count, Edge.Box, BorderStyle.Single, 0.5);
            }
        }