/// <summary> /// Print sample document with the specified QR bill /// </summary> /// <param name="bill">QR bill to print</param> internal static void Print(Bill bill) { // show print dialog var pd = new PrintDialog(); pd.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4); pd.PrintTicket.PageOrientation = PageOrientation.Portrait; if (pd.ShowDialog() != true) { return; } // create page var pageSize = new Size(pd.PrintableAreaWidth, pd.PrintableAreaHeight); var page = new FixedPage { Width = pageSize.Width, Height = pageSize.Height }; // add title var text = new TextBlock { Text = "Swiss QR Bill", FontSize = 40, FontWeight = FontWeights.Bold, Margin = new Thickness(20 / 25.4 * 96) }; page.Children.Add(text); // add QR bill to the bottom var qrBill = new Image { Source = QrBillImage.CreateImage(bill) }; FixedPage.SetBottom(qrBill, 0); page.Children.Add(qrBill); // create document var document = new FixedDocument(); document.DocumentPaginator.PageSize = pageSize; PageContent pageContent = new PageContent(); ((IAddChild)pageContent).AddChild(page); document.Pages.Add(pageContent); // print document pd.PrintDocument(document.DocumentPaginator, "Invoice"); }
public MainWindow() { InitializeComponent(); // create bill data 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" }; billImage.Source = QrBillImage.CreateImage(bill); }