private Task GenerateAndCompareBill(Bill bill) { bill.Format.OutputSize = OutputSize.A4PortraitSheet; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] imageData = QRBill.Generate(bill); return(VerifyImages.VerifySvg(imageData)); }
private void GenerateAndCompareBill(Bill bill, string expectedFileName) { bill.Format.OutputSize = OutputSize.A4PortraitSheet; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] imageData = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(imageData, expectedFileName); }
private Task GenerateAndCompareBill(Bill bill, GraphicsFormat graphicsFormat, SeparatorType separatorType) { bill.Format.GraphicsFormat = graphicsFormat; bill.Format.SeparatorType = separatorType; byte[] imageData = QRBill.Generate(bill); return(VerifyImages.Verify(imageData, graphicsFormat)); }
/// <summary> /// Generates a QR bill and saves it as a SVG file. /// </summary> static void Main() { // Setup bill data Bill bill = new Bill { // creditor data Account = "CH4431999123000889012", Creditor = new Address { Name = "Robert Schneider AG", AddressLine1 = "Rue du Lac 1268/2/22", AddressLine2 = "2501 Biel", CountryCode = "CH" }, // payment data Amount = 199.95m, Currency = "CHF", // debtor data Debtor = new Address { Name = "Pia-Maria Rutschmann-Schnyder", AddressLine1 = "Grosse Marktgasse 28", AddressLine2 = "9400 Rorschach", CountryCode = "CH" }, // more payment data Reference = "210000000003139471430009017", UnstructuredMessage = "Abonnement für 2020", // output format Format = new BillFormat { Language = Language.DE, GraphicsFormat = GraphicsFormat.SVG, OutputSize = OutputSize.QrBillOnly } }; // Generate QR bill as SVG byte[] svg = QRBill.Generate(bill); // Save generated SVG file const string path = "qrbill.svg"; File.WriteAllBytes(path, svg); Console.WriteLine($"SVG QR bill saved at { Path.GetFullPath(path) }"); // Generate QR bill as PNG bill.Format.GraphicsFormat = GraphicsFormat.PNG; byte[] png = QRBill.Generate(bill); // Save generated PNG file const string pngPath = "qrbill.png"; File.WriteAllBytes(pngPath, png); Console.WriteLine($"PNG QR bill saved at { Path.GetFullPath(pngPath) }"); }
private Task GenerateAndCompareBill(Bill bill, OutputSize outputSize, GraphicsFormat graphicsFormat) { bill.Format.OutputSize = outputSize; bill.Format.GraphicsFormat = graphicsFormat; byte[] imageData = QRBill.Generate(bill); return(VerifyImages.Verify(imageData, graphicsFormat)); }
private void GenerateAndCompareBill(Bill bill, GraphicsFormat graphicsFormat, SeparatorType separatorType, string expectedFileName) { bill.Format.GraphicsFormat = graphicsFormat; bill.Format.SeparatorType = separatorType; byte[] imageData = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(imageData, expectedFileName); }
private void GenerateAndCompareBill(Bill bill, OutputSize outputSize, GraphicsFormat graphicsFormat, string expectedFileName) { bill.Format.OutputSize = outputSize; bill.Format.GraphicsFormat = graphicsFormat; byte[] imageData = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(imageData, expectedFileName); }
private Task GenerateAndCompareBill(Bill bill, OutputSize outputSize, GraphicsFormat graphicsFormat) { bill.Format.OutputSize = outputSize; bill.Format.GraphicsFormat = graphicsFormat; bill.Format.FontFamily = "Arial,\"Liberation Sans\""; byte[] imageData = QRBill.Generate(bill); return(VerifyImages.VerifyPng(imageData)); }
public Task CreateQrBill5() { Bill bill = SampleData.CreateExample3(); bill.Format.OutputSize = OutputSize.QrBillExtraSpace; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
public Task CreateQrBillFrench() { Bill bill = SampleData.CreateExample1(); bill.Format.GraphicsFormat = GraphicsFormat.SVG; bill.Format.Language = Language.FR; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
private void QrCodeAsSvg4() { Bill bill = SampleData.CreateExample4(); bill.Format.OutputSize = OutputSize.QrCodeOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrcode_ex4.svg"); }
private static void GenerateWithInvalidData1() { Bill bill = SampleData.CreateExample1(); bill.Creditor.Name = " "; bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.PDF; QRBill.Generate(bill); }
public void CreateQrBill5() { Bill bill = SampleData.CreateExample3(); bill.Format.OutputSize = OutputSize.QrBillWithHorizontalLine; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_ex5.svg"); }
public void CreateQrBillFrench() { Bill bill = SampleData.CreateExample1(); bill.Format.GraphicsFormat = GraphicsFormat.SVG; bill.Format.Language = Language.FR; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_fr.svg"); }
public void CreateQrBill4() { Bill bill = SampleData.CreateExample4(); bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_ex4.svg"); }
public Task QrCodeAsSvg4() { Bill bill = SampleData.CreateExample4(); bill.Format.OutputSize = OutputSize.QrCodeOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
public Task SvgWithChallengingCharacters() { Bill bill = SampleData.CreateExample1(); bill.UnstructuredMessage = "<h1>&&\"ff\"'t'"; bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg)); }
private static void GenerateWithInvalidData3() { Bill bill = SampleData.CreateExample1(); bill.Reference = "RF1234"; bill.Currency = "XXX"; bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.PDF; QRBill.Generate(bill); }
private static void GenerateWithInvalidData2() { Bill bill = SampleData.CreateExample1(); bill.UnstructuredMessage = null; bill.BillInformation = "//" + new String('X', 150); bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.PDF; QRBill.Generate(bill); }
public void SvgWithChallengingCharacters() { Bill bill = SampleData.CreateExample1(); bill.UnstructuredMessage = "<h1>&&\"ff\"'t'"; bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_sc1.svg"); }
public void CreateQrBill5b() { Bill bill = SampleData.CreateExample3(); #pragma warning disable CS0618 // Type or member is obsolete bill.Format.OutputSize = OutputSize.QrBillWithHorizontalLine; #pragma warning restore CS0618 // Type or member is obsolete bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, "qrbill_ex5.svg"); }
static void Main(string[] args) { using (var doc = new PdfDocument()) { var page = doc.AddPage(); using (var graphic = XGraphics.FromPdfPage(page, XGraphicsUnit.Millimeter)) { graphic.DrawString("Test Invoice", new XFont("Arial", 20.0), XBrushes.Black, 20.0, 150.0); } using (var canvas = new PdfSharpCanvas(page, "Arial")) { QRBill.Draw(Bill, canvas); } doc.Save("Output.pdf"); } File.WriteAllBytes("OutputOriginal.pdf", QRBill.Generate(Bill)); }
static void Main(string[] args) { // Setup bill data Bill bill = new Bill { // creditor data Account = "CH4431999123000889012", Creditor = new Address { Name = "Robert Schneider AG", AddressLine1 = "Rue du Lac 1268/2/22", AddressLine2 = "2501 Biel", CountryCode = "CH" }, // payment data Amount = 199.95m, Currency = "CHF", // debtor data Debtor = new Address { Name = "Pia-Maria Rutschmann-Schnyder", AddressLine1 = "Grosse Marktgasse 28", AddressLine2 = "9400 Rorschach", CountryCode = "CH" }, // more payment data Reference = "210000000003139471430009017", UnstructuredMessage = "Abonnement für 2020" }; // Generate QR bill byte[] svg = QRBill.Generate(bill); // Save generated SVG file const string path = "qrbill.svg"; File.WriteAllBytes(path, svg); Console.WriteLine($"QR bill saved at { Path.GetFullPath(path) }"); }
private void GenerateQRBill(string locale, string expectedFileName) { CultureInfo savedCurrentCulture = CultureInfo.CurrentCulture; CultureInfo savedCurrentUiCulture = CultureInfo.CurrentUICulture; CultureInfo culture = CultureInfo.CreateSpecificCulture(locale); try { CultureInfo.CurrentCulture = culture; CultureInfo.CurrentUICulture = culture; Bill bill = SampleData.CreateExample3(); bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); FileComparison.AssertFileContentsEqual(svg, expectedFileName); } finally { CultureInfo.CurrentCulture = savedCurrentCulture; CultureInfo.CurrentUICulture = savedCurrentUiCulture; } }
public Task CurrentCulture(string locale) { CultureInfo savedCurrentCulture = CultureInfo.CurrentCulture; CultureInfo savedCurrentUiCulture = CultureInfo.CurrentUICulture; CultureInfo culture = CultureInfo.CreateSpecificCulture(locale); try { CultureInfo.CurrentCulture = culture; CultureInfo.CurrentUICulture = culture; Bill bill = SampleData.CreateExample3(); bill.Format.OutputSize = OutputSize.QrBillOnly; bill.Format.GraphicsFormat = GraphicsFormat.SVG; byte[] svg = QRBill.Generate(bill); return(VerifyImages.VerifySvg(svg).UseParameters(locale)); } finally { CultureInfo.CurrentCulture = savedCurrentCulture; CultureInfo.CurrentUICulture = savedCurrentUiCulture; } }