manuelbl / swissqrbill.net Goto Github PK
View Code? Open in Web Editor NEW.NET library for Swiss QR bill payment slips (aka QR-Rechnung)
License: MIT License
.NET library for Swiss QR bill payment slips (aka QR-Rechnung)
License: MIT License
Is it possible to Sign the assemblies? (Strong Naming)
Because to avoid tampering and because of a Third Party Component. I sign my Assemblies, But this requires that all referenced Assemblies are signed.
Changes in the Project file (in Project):
<PropertyGroup>
<AssemblyOriginatorKeyFile>Keyfile.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
Or Visual:
The structured bill information is currently being returned as raw string by the QrBill.DecodeQrCodeText
, do you plan on decoding that as well? Or would you accept a PR (since we would need to implement it ourselves in any case)?
Bei einem Kunden ist die Version 2.5.2.0 des SwissQRBill.NET Generators in Verwendung.
Erzeugt er eine QR-Rechnung und prüft die Rechnung danach mit der Testplattform von PostFinance, erhält er jeweils den folgenden Hinweis:
Zeile;Datenelement;Meldungsart;Meldungstext
32;Rechnungsinformationen;Hinweis;Das Element 'StrdBkgInf' darf nur geliefert werden, wenn es auch befüllt ist.
Die Rechnungsinformationen bzw. Bill.BillInformation wird beim Erstellen der QR-Rechnung nicht befüllt.
Es ist aber nicht null zugewiesen, sondern ein leerer String.
Ist dieser Fehler bekannt und in einer aktuelleren Version behoben?
According to the README file PNG is supported. Unfortunately I can't find the method to create a PNG file. Shouldn't there be a PNG flag in the GraphicsFormat enum?
Dear Manuel
The scissors are truncated and it has no separator line (see screenshot)
Format:
{
"Format": {
"Language": "DE",
"OutputSize": "QrBillExtraSpace",
"FontFamily": "Arial",
"SeparatorType": "SolidLineWithScissors",
"FileType": "png"
},
...
}
Thank you for your support.
Kind regards
Raphae
l
Hi there,
Apache FOP is unable to properly render the QR-code that SwissQRBill generates as SVG file.
This is due to a bug in the AFP renderer of Apache FOP: https://issues.apache.org/jira/browse/FOP-3058
The problem is related to the path of the Swiss cross that SwissQRBill generates.
The cross is described as
<path fill="#FFFFFF" shape-rendering="crispEdges"
d="M63.543,-70.709h3.307v11.024h-3.307zm-3.858,3.858h11.024v3.307h-11.024z"/>
Unfortunately, FOP doesn't interpret this white cross correctly when generating an AFP file, and adds a black square in the middle of the Swiss cross.
Would it be okay to change the way the cross is added to the QR code?
<!-- 2 Rectangles as workaround for Bug in FOP's AFP-Renderer -->
<rect x="59.685" y="-66.85" width="11.024" height="3.307" fill="#FFFFFF"/>
<rect x="63.543" y="-70.709" height="11.024" width="3.307" fill="#FFFFFF"/>
I am fully aware that this would only be a workaround for a bug in a different software library, but it would certainly be much simpler and quicker to implement this workaround in SwissQRBill.
What do you reckon?
Kind regards,
Reureu
Wenn die QR-Rechnung mit OutputSize.A4PortraitSheet gezeichnet wird, erscheint sowohl oberhalb als auch zwischen Empfangsschein und Zahlteil eine gestrichelte Linie mit Scherensymbol. Wird die QR-Rechnung mit OutputSize.QrBillOnly gezeichnet, erscheint die Perforation nur zwischen Empfangsschein und Zahlteil aber nicht oberhalb der beiden Elemente. Gibt es eine Möglichkeit die Ausgabe der Perforation zu steuern, damit sie auch bei OutputSize.QrBillOnly oberhalb der Elemente Empfangsschein und Zahlteil gezeichnet wird?
P.S. Herzlichen Dank für die Korrektur in V2.2.1 :)
Hello there,
I'm having a problem using the package.
{"Could not load file or assembly 'Codecrete.SwissQRBill.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=6aa6bd7a159d47c2'
or one of its dependencies. The system cannot find the file specified.":"Codecrete.SwissQRBill.Core, Version=2.4.0.0, Culture=neutral, PublicKeyToken=6aa6bd7a159d47c2"}
It looks like that the 2.4.0.0 in the Core.csproj was not updated
I'm running .Net Standard 2.0 project on the win machine
Can you help?
Thank you
QrCodeText.Decode
deliberately ignores the reference type, why? Could you add it to the returned structure? (...or would you take a PR with that fix into consideration?)
https://github.com/manuelbl/SwissQRBill.NET/blob/master/Generator/QRCodeText.cs#L200
I would like the customer name to be multiline. All attempts with "\r\n" or "\r" or "\n" were unsuccessful, everything is displayed on one line.
bill.Debtor.Name = "Firma XY" + "\r" + "Herr Vorname Nachname"
I'm porting an old red invoice to QR.
AFAIK, the whole conceptually not thought through QR thing is new-line sensitive.
But SwissQRBill.Generator.Bill.UnstructuredMessage allows messages with newlines.
Is this correct ?
RPT_ES_Zweck => UnstructuredMessage
SELECT [...]
,
'Rechnungs-Nr. '
+
FORMAT(KZ_Druck_Datum, 'yyyy')
+
'_'
+
CASE
WHEN LEN(KZ_Druck_Auftragsnummer) > 4 THEN FORMAT(KZ_Druck_Auftragsnummer, '00000')
WHEN LEN(KZ_Druck_Auftragsnummer) > 3 THEN FORMAT(KZ_Druck_Auftragsnummer, '0000')
ELSE FORMAT(KZ_Druck_Auftragsnummer, '000')
END
+
CHAR(10) + CHAR(13)
+
'KOA 8300 9901/PC DL-IT'
+
CHAR(10) + CHAR(13)
+
'Copycenter'
AS RPT_ES_Zweck
FROM [...]
Hi,
I've a working .net 4.62 project that generates QR bill with Codecrete.SwissQRBill.Generator 2.5.3 version.
I've tryed to update to 3.0.1 version and I got this exception :
Impossible de charger le fichier ou l'assembly 'SkiaSharp, Version=2.80.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' ou une de ses dépendances. Impossible de vérifier la signature de nom fort. L'assembly a pu être falsifié ou il est à signature différée, mais pas totalement signé avec la clé privée correcte. (Exception de HRESULT : 0x80131045)
The code is ;
"
using (PNGCanvas canvas = new PNGCanvas(QRBill.QrBillWidth, QRBill.QrBillHeight, 300, "Helvetica, Arial, Sans"))
{ ..... }
"
I rollback to 2.5.3 and it work fine
Thank's a lot for help
Best regards,
Herve
Hi,
I've a working .net 4.8 project that generates QR bill with Codecrete.SwissQRBill.Generator 2.5.3 version.
I've tryed to update to 3.0.0 version but I got this exception.
Graphics format PNG not available (are you missing the NuGet package Codecrete.SwissQRBill.Generator?)
I've this packages installed:
Codecrete.SwissQRBill.Generator 3.0.0 and Net.Codecrete.QrCodeGenerator 2.0.1
Try to with Codecrete.SwissQRBill.Core 3.0.0 (same result)
What I have to do to get the last version working?
Kind regards.
There are published images for the scissor and the corner marks, see that:
https://www.paymentstandards.ch/de/shared/communication-grid/eckmarken.html
And for the swiss cross too:
[https://www.paymentstandards.ch/de/shared/communication-grid/swiss-qr-code.html]https://www.paymentstandards.ch/de/shared/communication-grid/swiss-qr-code.html
Otherwise great job!
It seems that even if I don't specify an AlternativeSchemes, the qr is invalid by postfinance (see below). Strangely by UBS it does work. Any Idea why ? I tried also to put AlternativeSchemes =null.
// Setup bill data
Bill bill = new Bill
{
// creditor data
Account = qriban,
Creditor = new Address
{
Name = values[10],
AddressLine1 = values[12],
AddressLine2 = values[13],
CountryCode = "CH"
},
// payment data
Amount = amount,
Currency = "CHF",
// debtor data
Debtor = new Address
{
Name = values[17],
AddressLine1 = values[22] + " " + values[21],
AddressLine2 = values[25] + " " + values[24],
CountryCode = "CH"
},
// more payment data
Reference = values[51],
UnstructuredMessage = values[39],
// If it's commented or not still doesnt work
//AlternativeSchemes = new List<AlternativeScheme>(){
// new AlternativeScheme()
// {
// Instruction = "test",
// Name = "test"
// }
//},
// format
Format = new BillFormat
{
Language = Language.FR
}
};
Fichier : FactureQR-V016-2020-01-26-20210126-084748-20210519-130534.pdf.xml
Type : Facture QR
--------------------------------------------------------------------
Résultat :
La structure du fichier est incorrecte.
Erreurs : 1
Avertissements : 0
Remarques : 0
Erreurs
--------------------------------------------------------------------
Erreur dans la structure de l'élément de données du code QR /QRCH/AltPmtInf/AltPmt[1]
Message d'erreur :
L'élément 'AltPmt' doit uniquement être fournis s'il n'est pas vide.
================================================================================
I am trying to create bill with slovenian IBAN and I keep getting error account_is_ch_li_iban.
I used this site https://www.iban.com/iban-checker to check my IBAN and it is valid
IBAN that's failing: SI56610000003603509.
Why is this working only for Liechtenstein and Switzerland?
According to the "Swiss Implementation Guidelines QR-bill" (Annex D: Multilingual glossary), the french value for the key "PaymentPart" should be "Section paiement" (instead of "Section de paiement"), and the italian value should be "Sezione pagamento" (instead of "Sezione di pagamento").
https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-en.pdf
Hello,
according to every SPEC, your nuget should be compatible, but it doesnt install in PM console:
PM> NuGet\Install-Package Codecrete.SwissQRBill.Core -Version 3.0.6
Installing 'Codecrete.SwissQRBill.Core 3.0.6'.
Successfully installed 'Codecrete.SwissQRBill.Core 3.0.6'.
Adding 'Codecrete.SwissQRBill.Core 3.0.6' to SwissQR.
Uninstalling 'Codecrete.SwissQRBill.Core 3.0.6'.
Successfully uninstalled 'Codecrete.SwissQRBill.Core 3.0.6'.
Install failed. Rolling back...
NuGet\Install-Package : Could not install package 'Codecrete.SwissQRBill.Core 3.0.6'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.2', but the package does not contain any
assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Thank you for the great job with this SwissQR!
However, I experienced an issue with the IBAN I want to use. It causes errors in the .Net version.
I first tested the Nuget package and got errors.
Then I tested the source code and tried to find a Unit Test to reproduce the error.
The IBAN I want to use is accepted in the IBAN validation Unit Test. For exemple it is OK if I add:
public
void ValidJCS() { Assert.True(Payments.IsValidIban("CH23 0900 0000 1275 7975 8")); }`
However, when it comes down to generate an Invoice, this IBAN fails. For example, if I add the following code to QRBillTest.cs:
[Fact]
public void CreateQrBillJCS1()
{
// Test with default sample data from Example1
Bill bill = SampleData.CreateExample1();
bill.Format.GraphicsFormat = GraphicsFormat.SVG;
bill.Format.Language = Language.FR;
const string path1 = "qrbill_jcs1.svg";
byte[] svg1 = QRBill.Generate(bill);
System.IO.File.WriteAllBytes(path1, svg1);
Assert.True(System.IO.File.Exists(path1));
}
[Fact]
public void CreateQrBillJCS2()
{
// Test with default sample data from Example1, then change the IBAN to a real one in Switzerland
Bill bill = SampleData.CreateExample1();
bill.Account = "CH23 0900 0000 1275 7975 8";
bill.Format.GraphicsFormat = GraphicsFormat.SVG;
bill.Format.Language = Language.FR;
const string path2 = "qrbill_jcs2.svg";
byte[] svg2 = QRBill.Generate(bill);
System.IO.File.WriteAllBytes(path2, svg2);
Assert.True(System.IO.File.Exists(path2));
}`
The first test is OK, but the second (which only had a change of the IBAN) fails with this error:
QRBillValidationException : QR bill data is invalid
(It also fails with my private IBAN. If I test this IBAN on https://www.codecrete.net/qrbill/bill , it works, but not in the .Net implementation)
The problem is the same with the Nuget package which what I'd like to use....
I hope this will help you find what's wrong with the library...
Thank you for your help
Thank you very much for your reply. I compiled the sources on Win 10 (1909) with VS 2019 and and on an other machine with VS 2017 on Win 10 (1909). I tryed different .Net Versions with the same result. The software I wrote is a .Net Core 2.1 Application (VS2017) and integrates your lib with NuGet. Version is 2.3.4 (2.3.1 produces the same result).
The file can be read from Sumatra, Firefox or Edge (Chromium) and fails with Edge (older version) and Acrobat Reader DC (current version).
Stefan
Originally posted by @stefanDge in #18 (comment)
Hi,
first I want to say thank you for your job. It's excellent and very useful!
I've a question about the image quality, is it possible to set the quality of png image generated?
My image is a little bit low quality when I generate it.
Thank you for your support.
See dotnet/designs#234 (merged in Make System.Drawing.Common
only supported on Windows)
Using SkiaSharp or ImageSharp is the recommended alternative.
Note: I'm currently working on a Verify
branch that should make it easy to catch differences when changing the rendering engine (by displaying a visual diff of the generated QR-bills).
Hi there
According to the syntax definition version 1.2) dates have to be formatted like yymmdd (year, month, day). In practice I found quite a lot of invoices with dates formatted like yymmddhhmmss (year, month, day, hour, minute, second).
I could create a pull request so that both formats are accepted and parsed correctly. But before I do the work, I wanted to ask if such a pull request would be accepted at all.
BTW: Thank you for the great library!
Michael
Hi,
I use this great Library to create PDF-Files. It works fine with different PDF-Viewers, but Acrobat Reader reports error 14 „dict object expected“. Acrobat Reader opens and displays your reference files from the test-project without erros. When I run the tests, CreateA4PdfBill1() fails when files are compared. Analyzing the corrupted file the page-dimensions are shown as 595 x 0.
This is my testcode
bill.Format.GraphicsFormat = GraphicsFormat.PDF;
bill.Format.SeparatorType = SeparatorType.DottedLineWithScissors;
bill.Format.Language = Language.DE;
byte[] pdf = QRBill.Generate(bill);
File.WriteAllBytes(path, pdf);
when I use
PDFCanvas canvas = new PDFCanvas(QRBill.A4PortraitWidth, QRBill.A4PortraitHeight);
QRBill.Draw(bill, canvas);
canvas.SaveAs(path);
the same error comes up. Is there any solution for this problem?
Thank you very mutch in advance
Stefan
Hallo,
Wie funktioniert das, wenn eine Adresse mehre als 3 Linien benötigt?
Beispiel:
Name de Firma
Das Département
Die Adresse
CP 339393
3000 Bern
Ist es möglich der Name oder eine Adresse auf 2 Linien zu schreiben?
Wie zum Beispiel:
Name der Firma
Das Departement
Oder
Die Adresse
CP 33456
Ich habe gesehen das die «line feed» nicht funktionieren.
Gruss
David
Hallo
Auf der Testplattform von PostFinance gibt es eine visuelle Kontrolle. Im Anhang ist das Resultat der Prüfung einer QR-Rechnung zu finden, welche ich mit SwissQRBill.NET erstellt habe. Der QR-Code liegt ausserhalb des vorgegebenen Rahmens. Ist das ein Fehler bzw. ein Problem?
Besten Dank für ein Feedback!
Ist es möglich, die vertikale Perforationslinie nicht zu zeichnen?
Hintergrund: Kunde hat bereits performiertes Papier
It would be great to add twint (fields) and even ebill to qr bill.
Wenn man mit der PostFinance App die QR-Rechnungen scannt, kommt bei diversen Rechnungen mit Type QRR ein Error.
So auch mit dem Beispiel Example 4: Debtor to be filled in, in German.
Wir da etwas falsch generiert? Oder ist das möglicherweise ein Bug in der PostFinance App? Mit der Raiffeisen App klappt es prima.
Is it possible to generate a QrCode (QrCodeOnly without the entire payment slip) that has a quite zone (white margin) around it? If not, would it be possible to add such a feature?
When testing the generated QR bills against several banking solutions several portals raises the following error:
The last delivered data element must not be terminated with a line feed (CR + LF or LF).
"Das letzte gelieferte Datenelement darf nicht mit einer Zeilenschaltung (CR + LF bzw. LF) abgeschlossen werden."
For more infos, check paragraph 4.2.4:
https://www.paymentstandards.ch/dam/downloads/ig-qr-bill-de.pdf
I verified the contained QR data and "they" are correct, at the moment an empty line closes the payment/qr data
I guess the font size of Amount should be same as other text, or?
BillLayout.cs about line 177 graphics.PutText(_amount, currencyWidthPp, y, _labelFontSize, false);
-> _textFontSize
Did some testing with with the library ... makes to me a very good impression ... everything works as expected so far
... I learned quite few things about good coding und pdf generation..
Thank you very much
User Werni <werner....@...> sends the following message to the owners of Package 'Codecrete.SwissQRBill.Generator 2.0.0'.
Hallo Manuel
Wenn das QR-File eine leere Zeile zu viel enthält so wird eine Exception geworfen. Das PDF wurde nicht von uns generiert und ich weiss das es nicht korrekt ist. Wäre gut wenn in diesem Fall die Zeile einfach ignoriert wird und keine Exception geworfen wird.
Meldung: ValidationException QR bill data is invalid: Message: qrTextLocalized error message: Valid data structure starts with SPC and consists 32 to 34 lines of text.
Danke und Gruss
Werner
Hello everyone!
I am upgrading from version 2.4.3 to version 3.0.5 and I get this exception when I want to generate the QR Bill in .PNG format.
Codecrete.SwissQRBill.Generator.QRBillGenerationException: 'Graphics format PNG not available (are you missing the NuGet package Codecrete.SwissQRBill.Generator?)'
Works well in SVG and PDF formats.
The framework of my project is .NET 4.6.1.
Supposedly this issue was fixed with version 3.0.1, in my case it is not.
Graphics format PNG not available
Thank you in advance.
Würde ein (forcierter) Zeilenumbruch im Feld "Zusätzliche Informationen" gegen die Spezifikation verstossen?
It looks like currently the font specified in BillFormat
does not get embedded in the generated PDF.
Embedding fonts would be a nice feature to make sure the result looks the same on every system, especially when using less common fonts like "Liberation Sans" (which has the least permissive license of all the fonts allowed by the QR bill specification).
Ideally such an implementation would allow to provide a custom font resolver (use case: PDFs generated on a server where no fonts are available on the system). As an example, PDFsharp allows for custom font resolvers using an interface like this:
https://github.com/empira/PDFsharp/blob/master/src/PdfSharp/Fonts/IFontResolver.cs
Actually it's impossible to have address with 3 lines. The insurances use some time this.
Example:
HELVETIA PATRIA ASSURANCES
RUE DENT-BLANCHE 20
CASE POSTALE 717
1950 Sion
We have some client that can't send the bills because the address on the QRCode is incorrect.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.