### Generate QR Bill as SVG Source: https://github.com/manuelbl/swissqrbill/blob/master/README.md Example demonstrating how to set up bill data and generate a QR bill in SVG format. Ensure necessary imports are included. The generated SVG is saved to a file. ```java package net.codecrete.qrbill.examples; import net.codecrete.qrbill.generator.Address; import net.codecrete.qrbill.generator.Bill; import net.codecrete.qrbill.generator.QRBill; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class QRBillExample { public static void main(String[] args) { // Setup bill Bill bill = new Bill(); bill.setAccount("CH4431999123000889012"); bill.setAmountFromDouble(199.95); bill.setCurrency("CHF"); // Set creditor Address creditor = new Address(); creditor.setName("Robert Schneider AG"); creditor.setStreet("Rue du Lac"); creditor.setHouseNo("1268/2/22"); creditor.setPostalCode("2501"); creditor.setTown("Biel"); creditor.setCountryCode("CH"); bill.setCreditor(creditor); // more bill data bill.setReference("210000000003139471430009017"); bill.setUnstructuredMessage("Abonnement für 2020"); // Set debtor Address debtor = new Address(); debtor.setName("Pia-Maria Rutschmann-Schnyder"); debtor.setStreet("Grosse Marktgasse"); debtor.setHouseNo("28"); debtor.setPostalCode("9400"); debtor.setTown("Rorschach"); debtor.setCountryCode("CH"); bill.setDebtor(debtor); // Set output format BillFormat format = new BillFormat(); format.setGraphicsFormat(GraphicsFormat.SVG); format.setOutputSize(OutputSize.QR_BILL_ONLY); format.setLanguage(Language.DE); bill.setFormat(format); // Generate QR bill byte[] svg = QRBill.generate(bill); // Save QR bill Path path = Paths.get("qrbill.svg"); try { Files.write(path, svg); } catch (IOException e) { throw new RuntimeException(e); } System.out.println("QR bill saved at " + path.toAbsolutePath()); } ``` -------------------------------- ### Build and Run with Maven Source: https://github.com/manuelbl/swissqrbill/blob/master/examples/jasper_reports_rendering/README.md Execute this command to clean the project, package it, and run the Java application. This process compiles Jasper reports and generates a PDF file. ```text $ mvn clean package exec:java [INFO] Scanning for projects... [INFO] [INFO] -----------< net.codecrete.qrbill:jasper-reports-rendering >------------ [INFO] Building Jasper Reports Rendering 3.1.1 [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- clean:3.1.0:clean (default-clean) @ jasper-reports-rendering --- [INFO] [INFO] --- jasperreports:3.5.6:jasper (default) @ jasper-reports-rendering --- [INFO] Compiling 1 Jasper reports design files. [INFO] Generated 1 jasper reports in 0.424 seconds [INFO] [INFO] --- resources:3.0.2:resources (default-resources) @ jasper-reports-rendering --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 6 resources [INFO] [INFO] --- compiler:3.8.0:compile (default-compile) @ jasper-reports-rendering --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 3 source files to /Users/me/Documents/SwissQRBill/examples/jasper_reports_rendering/target/classes [INFO] [INFO] --- resources:3.0.2:testResources (default-testResources) @ jasper-reports-rendering --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/me/Documents/SwissQRBill/examples/jasper_reports_rendering/src/test/resources [INFO] [INFO] --- compiler:3.8.0:testCompile (default-testCompile) @ jasper-reports-rendering --- [INFO] No sources to compile [INFO] [INFO] --- surefire:2.22.1:test (default-test) @ jasper-reports-rendering --- [INFO] No tests to run. [INFO] [INFO] --- jar:3.0.2:jar (default-jar) @ jasper-reports-rendering --- [INFO] Building jar: /Users/me/Documents/SwissQRBill/examples/jasper_reports_rendering/target/jasper-reports-rendering-3.1.1.jar [INFO] [INFO] --- exec:3.0.0:java (default-cli) @ jasper-reports-rendering --- 119077 bytes written to invoices.pdf. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.179 s [INFO] Finished at: 2023-07-09T22:17:59+02:00 [INFO] ------------------------------------------------------------------------ ``` -------------------------------- ### Generate QR Bill in Kotlin Source: https://github.com/manuelbl/swissqrbill/blob/master/examples/kotlin_example/README.md This snippet shows the fundamental steps to create a QR bill using Kotlin. It requires the necessary QR bill library to be included in your project. ```kotlin import ch.fha.qr.model.QRBill import ch.fha.qr.generator.QRBillGenerator fun main() { // Create a QRBill object with necessary details val qrBill = QRBill( amount = 100.50, currency = "CHF", beneficiary = "Beneficiary Name", address = "Beneficiary Address", reference = "RF12345678901234567890", message = "Payment for invoice 12345" ) // Generate the QR bill image val generator = QRBillGenerator() val qrCodeImage = generator.generate(qrBill) // Save or display the QR code image // For example, save to a file: // qrCodeImage.save("qr_bill.png") println("QR Bill generated successfully.") } ``` -------------------------------- ### Generate QR Bill as PNG Source: https://github.com/manuelbl/swissqrbill/wiki/Generate-PNG-files Generates a QR bill and saves it as a PNG file. Requires a PNGCanvas instance with a specified resolution. A resolution of 144 pixels per inch is recommended. ```java package net.codecrete.qrbill.examples; import net.codecrete.qrbill.generator.Address; import net.codecrete.qrbill.generator.Bill; import net.codecrete.qrbill.generator.QRBill; import net.codecrete.qrbill.canvas.PNGCanvas; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class QRBillExample { public static void main(String[] args) { // Setup bill Bill bill = new Bill(); bill.setLanguage(Bill.Language.fr); bill.setAccount("CH4431999123000889012"); // ... // see https://github.com/manuelbl/SwissQRBill // ... debtor.setCountryCode("CH"); bill.setDebtor(debtor); PNGCanvas canvas = new PNGCanvas(144); byte[] png = QRBill.generate(bill, canvas); Path path = Paths.get("qrbill.png"); try { Files.write(path, png); } catch (IOException e) { throw new RuntimeException(e); } System.out.println("QR bill saved at " + path.toAbsolutePath()); } } ``` -------------------------------- ### Add QR Bill to Existing PDF (C# with iText 7) Source: https://github.com/manuelbl/swissqrbill/wiki/Add-to-existing-PDF This C# snippet demonstrates adding a QR bill to an existing PDF using iText 7. It requires the Bill data, paths to the input and output PDFs, and a custom IText7Canvas implementation. ```csharp Bill bill = ...; // bill data string invoiceWithoutQRBill = ...; // path to existing PDF string invoiceWithQRBill = ...; // path to new PDF using (FileStream fs = new FileStream(invoiceWithQRBill, FileMode.Create)) using (IText7Canvas canvas = new IText7Canvas(OpenPdfInvoice(invoiceWithoutQRBill), fs, IText7Canvas.LastPage)) { QRBill.Draw(bill, canvas); } ``` -------------------------------- ### Add Gradle Dependency for QR Bill Generator Source: https://github.com/manuelbl/swissqrbill/blob/master/README.md Add this line to your Gradle project's build.gradle file to include the QR bill generator library. ```gradle implementation "net.codecrete.qrbill:qrbill-generator:3.4.0+" ``` -------------------------------- ### Add Maven Dependency for QR Bill Generator Source: https://github.com/manuelbl/swissqrbill/blob/master/README.md Include this dependency in your Maven project's pom.xml to use the QR bill generator library. ```xml net.codecrete.qrbill qrbill-generator [3.4.0,3.999999] ``` -------------------------------- ### Add QR Bill to Last Page (Java) Source: https://github.com/manuelbl/swissqrbill/wiki/Add-to-existing-PDF Use this Java snippet to add a QR bill to the last page of an existing PDF. Ensure you have the Bill data and paths for the input and output PDFs. ```java Bill bill = ...; // bill data Path invoiceWithoutQRBill = ...; // path to existing PDF Path invoiceWithQRBill = ...; // path to new PDF try (PDFCanvas canvas = new PDFCanvas(invoiceWithoutQRBill, PDFCanvas.LAST_PAGE)) { QRBill.draw(bill, canvas); canvas.saveAs(invoiceWithQRBill); } ``` -------------------------------- ### Disable SVG Shape Conversion in Jasper Reports Source: https://github.com/manuelbl/swissqrbill/blob/master/examples/jasper_reports_rendering/README.md This property can be set to control SVG shape conversion in Jasper Reports. However, it may not have a significant effect when Batik is used in the graphics pipeline. ```properties net.sf.jasperreports.export.pdf.force.svg.shapes=false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.