manuelbl / SwissQRBill

Java library for Swiss QR bill payment slips (aka QR-Rechnung)
https://www.codecrete.net/qrbill
MIT License
153 stars 36 forks source link

Increase size of qr #80

Closed gomesm1209 closed 1 year ago

gomesm1209 commented 1 year ago

Hi,

I use your librairy for generate our QRBilll and the bank say that the QR-Code need to be bigger 46x46mm. How can I increase the size?

The bank say also that the position need to be corrected. How can I do that with your library?

(see example on attachement) Thanks in advance Marine

manuelbl commented 1 year ago

I am pretty sure that this library creates QR bills with the correct size and position.

In the attached PDF file, I note that the dashed lines do not go to the edge of the paper, neither on the left and right side, nor at the bottom. So the QR bill has been scaled and re-positioned.

Assuming that the original document was a PDF and was correct, it could be caused by a PDF viewer software used to print the QR bill. Most of them (including browsers) tend to scale the PDF to about 95% to make it "fit to page width". Whoever annotated the QR bill is also aware of this general challenge with QR bills sent by email and printed by the customer ("check your printer settings")

You don't provide any information how the PDF was generated. Was it directly generated by this library? Or was the QR bill inserted into another document, which then generated a PDF or similar document? In the latter case, many additional causes are possible.

Please also note that the document anonymization is moot. The covered information is also contained in the QR code and can be revealed by any smartphone.

gomesm1209 commented 1 year ago

Hi

I think I found the solution by putting as OutputSize QR_BILL_EXTRA_SPACE. By the way, Laser printer cannot print without border, this ist he reason that the dashed lines do not go to the edge of the paper.

Regards,

Marine

@.***+41%2026%20401%2088%2088> [cid:683e9c5e-e975-4941-9ce8-2948641ba9b4.jpg] [cid:megahertz_logo-30ans_small_0200a338-e124-4c1a-9dd2-742d5a144692.png]

Marine Gomes Informaticienne

D. +41 26 401 88 88 linkedin.com/company/megahertzch<tel:linkedin.com/company/megahertzch> [cid:Logo_MS_Office_f2460e2c-2677-4990-9e9d-48f0f3bae5a9.png] megahertz computer sa Route du Coteau 61 1752 Villars-sur-Glâne T. +41 26 407 74 74 www.megahertz.chhttp://www.megahertz.ch/ [cid:Email_signature_W1200xH60_e50a7f07-48cf-4b9e-a300-53d9573251e2.jpg]

megahertz computer sa prend soin de n'envoyer aucune information confidentielle par messagerie électronique. Cependant, ce message et toutes les pièces jointes sont établis par à l’intention exclusive de ses destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d’en avertir immédiatement l’expéditeur.

De : Manuel Bl. @.> Envoyé : mercredi, 28 septembre 2022 14:14 À : manuelbl/SwissQRBill @.> Cc : Marine Gomes @.>; Author @.> Objet : Re: [manuelbl/SwissQRBill] Increase size of qr (Issue #80)

I am pretty sure that this library creates QR bills with the correct size and position.

In the attached PDF file, I note that the dashed lines do not go to the edge of the paper, neither on the left and right side, nor at the bottom. So the QR bill has been scaled and re-positioned.

Assuming that the original document was a PDF and was correct, it could be caused by a PDF viewer software used to print the QR bill. Most of them (including browsers) tend to scale the PDF to about 95% to make it "fit to page width". Whoever annotated the QR bill is also aware of this general challenge with QR bills sent by email and printed by the customer ("check your printer settings")

You don't provide any information how the PDF was generated. Was it directly generated by this library? Or was the QR bill inserted into another document, which then generated a PDF or similar document? In the latter case, many additional causes are possible.

Please also note that the document anonymization is moot. The covered information is also contained in the QR code and can be revealed by any smartphone.

— Reply to this email directly, view it on GitHubhttps://github.com/manuelbl/SwissQRBill/issues/80#issuecomment-1260815092, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUSYZFONVSTXIGG236JRZJ3WAQZBLANCNFSM6AAAAAAQXNP7PY. You are receiving this because you authored the thread.Message ID: @.***>

manuelbl commented 1 year ago

I think I found the solution by putting as OutputSize QR_BILL_EXTRA_SPACE.

We don't have any details how you use the library. So it's difficult to comment. But it sounds strange.

By the way, Laser printer cannot print without border, this ist he reason that the dashed lines do not go to the edge of the paper.

Some printers even have a border of 10mm. In that case, not just the lines but also part of the text is cut off. It's also the reason why most software will automatically scale it down.

In the sample you have provided yesterday, it looked as if the document was scaled and not cut off. I derive this from the position of the text.

I doubt you have already gotten to the bottom of the cause. I'm happy to support you. But I would need the details of how the document is generated, what the overall process looks like (is the invoice sent by email and then printed by the cusotmer?) and I would need a sample of the QR bill (and not just a scanned version).

gomesm1209 commented 1 year ago

Hi,

We print the bill and send it to the customer. Here is my code that generated the bill:

Bill bill = new Bill(); bill.getFormat().setLanguage(Language.FR); bill.getFormat().setOutputSize(OutputSize.QR_BILL_EXTRA_SPACE);

bill.setAccount(fileStorageProperties.getBillAccount()); //bill.setAccount("CH4431999123000889012"); bill.setAmountFromDouble(facture.getNew_totalincltva()); bill.setCurrency("CHF");

Address creditor = new Address(); creditor.setName(facture.getBillto_name()); creditor.setAddressLine1(facture.getBillto_line1()); creditor.setAddressLine2(facture.getBillto_postalcode() + " "+facture.getBillto_city()); creditor.setCountryCode("CH");

String noClient = String.format("%06d",facture.getNew_no_client()); SimpleDateFormat yearformat = new SimpleDateFormat("yy"); String year = yearformat.format(new Date()); SimpleDateFormat monthFormat = new SimpleDateFormat("MM"); String month = monthFormat.format(new Date()); String facId = facture.getNew_nfacture().split("-")[1];

String reference = fileStorageProperties.getBvrb()+noClient+"00004"+ year + month + facId;

int sum =0; char [] c = reference.toCharArray(); for (int i = 0; i < c.length; i++) { int a = Integer.parseInt(String.valueOf(c[i])); sum = sum + a; }

bill.createAndSetQRReference(reference); System.out.println(bill.getReference()); bill.setUnstructuredMessage(facture.getNew_nfacture());

// Set debtor Address debtor = new Address(); debtor.setName("xxx "); debtor.setAddressLine1("xxxx"); debtor.setAddressLine2("xxxxx"); debtor.setCountryCode("CH"); bill.setDebtor(creditor); bill.setCreditor(debtor); Path invoiceWithoutQrBIll = this.fileStorageLocation.resolve(fileName).normalize();

BillFormat format = new BillFormat(); format.setOutputSize(OutputSize.A4_PORTRAIT_SHEET); format.setLanguage(Language.FR); format.setSeparatorType(SeparatorType.DASHED_LINE_WITH_SCISSORS); // format.setFontFamily("Frutiger Roman"); bill.setFormat(format); try(PDFCanvas canvas = new PDFCanvas(invoiceWithoutQrBIll, PDFCanvas.NEW_PAGE_AT_END)){ QRBill.draw(bill,canvas); Path path = Paths.get(fileName); canvas.saveAs(path); Files.deleteIfExists(invoiceWithoutQrBIll); logger.info(fileName+" saved at " + path.toAbsolutePath());; return new File(path.toUri());

} catch (IOException e) { e.printStackTrace(); }

And you can found in attachement the generate pdf.

Marine

@.***+41%2026%20401%2088%2088> [cid:683e9c5e-e975-4941-9ce8-2948641ba9b4.jpg] [cid:megahertz_logo-30ans_small_0200a338-e124-4c1a-9dd2-742d5a144692.png]

Marine Gomes Informaticienne

D. +41 26 401 88 88 linkedin.com/company/megahertzch<tel:linkedin.com/company/megahertzch> [cid:Logo_MS_Office_f2460e2c-2677-4990-9e9d-48f0f3bae5a9.png] megahertz computer sa Route du Coteau 61 1752 Villars-sur-Glâne T. +41 26 407 74 74 www.megahertz.chhttp://www.megahertz.ch/ [cid:Email_signature_W1200xH60_e50a7f07-48cf-4b9e-a300-53d9573251e2.jpg]

megahertz computer sa prend soin de n'envoyer aucune information confidentielle par messagerie électronique. Cependant, ce message et toutes les pièces jointes sont établis par à l’intention exclusive de ses destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le détruire et d’en avertir immédiatement l’expéditeur.

De : Manuel Bl. @.> Envoyé : jeudi, 29 septembre 2022 09:46 À : manuelbl/SwissQRBill @.> Cc : Marine Gomes @.>; Author @.> Objet : Re: [manuelbl/SwissQRBill] Increase size of qr (Issue #80)

I think I found the solution by putting as OutputSize QR_BILL_EXTRA_SPACE.

We don't have any details how you use the library. So it's difficult to comment. But it sounds strange.

By the way, Laser printer cannot print without border, this ist he reason that the dashed lines do not go to the edge of the paper.

Some printers even have a border of 10mm. In that case, not just the lines but also part of the text is cut off. It's also the reason why most software will automatically scale it down.

In the sample you have provided yesterday, it looked as if the document was scaled and not cut off. I derive this from the position of the text.

I doubt you have already gotten to the bottom of the cause. I'm happy to support you. But I would need the details of how the document is generated, what the overall process looks like (is the invoice sent by email and then printed by the cusotmer?) and I would need a sample of the QR bill (and not just a scanned version).

— Reply to this email directly, view it on GitHubhttps://github.com/manuelbl/SwissQRBill/issues/80#issuecomment-1261895181, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUSYZFJWTPP7UH7T6VCZM7DWAVCLJANCNFSM6AAAAAAQXNP7PY. You are receiving this because you authored the thread.Message ID: @.**@.>>

manuelbl commented 1 year ago

I'm afraid the attachment didn't arrive in the issue. You might want to log in to GitHub and respond in this issue instead of replying by email.

I've tested your code with some modification for missing instance variables like facture and fileStorageLocation. It works as expected and adds a new page to an existing PDF. For the QR bill payment slip, all the elements have the expected size and the dashed lines go to the edge of the page.

So causes are likely:

It would be helpful if you could try again to attach the resulting PDF file.

manuelbl commented 1 year ago

BTW: This is the PDF I'm get:

invoice.pdf