Пример #1
0
        public static byte[] generateQRcode(
            string account,
            string creditorName,
            string creditorAddressLine1,
            string creditorAddressLine2,
            string creditorCountryCode,
            decimal amount,
            string currency,
            string debtorName,
            string debtorAddressLine1,
            string debtorAddressLine2,
            string debtorCountryCode,
            string reference,
            string unstructuredMessage)
        {
            Bill bill = new Bill
            {
                Account  = account,
                Creditor = new Address
                {
                    Name         = creditorName,
                    AddressLine1 = creditorAddressLine1,
                    AddressLine2 = creditorAddressLine2,
                    CountryCode  = creditorCountryCode
                },
                Amount   = amount,
                Currency = currency,
                Debtor   = new Address
                {
                    Name         = debtorName,
                    AddressLine1 = debtorAddressLine1,
                    AddressLine2 = debtorAddressLine2,
                    CountryCode  = debtorCountryCode
                },
                Reference           = reference,
                UnstructuredMessage = unstructuredMessage
            };

            bill.Format.OutputSize = OutputSize.QrCodeOnly;

            string path = "qrbill.png";

            using (PNGCanvas canvas = new PNGCanvas(QRBill.QrBillWidth, QRBill.QrBillHeight, 144, "Arial"))
            {
                QRBill.DrawQrBillOnly(bill, canvas);
                canvas.SaveAs(path);
            }

            byte[] array = File.ReadAllBytes(Path.GetFullPath(path));

            return(array);
        }