QR code

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Jan 14, 2013
Company:

Hi all!
can i print 'qr' code on 1C ?

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, P& A.

To print a QR code you need an add-in.

 
#3
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Jan 14, 2013
Company:

Hello, Timofey Bugaevsky!

Thanks!

 
#4
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, P& A.

You can find the QR code generation add-in in attachments for this message, see qr.zip file.

To use this add-in you need to attach it and call GenerateQRCode() method.

I made an example for you. Please see the attached qrsample.cf file.

Code
&AtClient
Procedure ExecutePrintQRCode(Command)
   
   SpreadsheetDocument = PrintQRCode("More samples on 1C:Developer Network forum: http://1c-dn.com/forum/");
   If SpreadsheetDocument <> Undefined Then
      SpreadsheetDocument.Show(NStr("en = 'QR code sample'"));
   EndIf;
   
EndProcedure

&AtServer
Function PrintQRCode(QRString)
   
   SpreadsheetDocument = New SpreadsheetDocument;
   
   Template = GetCommonTemplate("QRCodeSample");
   Area = Template.GetArea("Output");
   
   QRCodeData = QRCodeData(QRString, 0, 190);
   
   If Not TypeOf(QRCodeData) = Type("BinaryData") Then
      
      UserMessage = New UserMessage;
      UserMessage.Text = NStr("en = 'Unable to generate QR code'");
      UserMessage.Message();
      
      Return Undefined;
   EndIf;
   
   QRCodePicture = New Picture(QRCodeData);
   
   Area.Drawings.QRCode.Picture = QRCodePicture;
   
   SpreadsheetDocument.Put(Area);
   
   Return SpreadsheetDocument;
   
EndFunction

&AtServer
Function QRCodeData(QRString, CorrectionLevel, Size) 
   
   ErrorMessage = НСтр("en = 'Unable to attach the QR code generation add-in.'");
   
   Try
      If AttachAddIn("CommonTemplate.QRCodeAddIn", "QR") Then
         QRCodeGenerator = New("AddIn.QR.QRCodeExtension");
      Else
         UserMessage = New UserMessage;
         UserMessage.Text = ErrorMessage;
         UserMessage.Message();
      EndIf
   Except
      DetailErrorDescription = DetailErrorDescription(ErrorInfo());
      UserMessage = New UserMessage;
      UserMessage.Text = ErrorMessage + Chars.LF + DetailErrorDescription;
      UserMessage.Message();
   EndTry;
   
   Try
      PictureBinaryData = QRCodeGenerator.GenerateQRCode(QRString, CorrectionLevel, Size);
   Except
      UserMessage = New UserMessage;
      UserMessage.Text = DetailErrorDescription(ErrorInfo());
      UserMessage.Message();
   EndTry;
   
   Return PictureBinaryData;
   
EndFunction

Download qr.zip (397.2 KB)
 
#5
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Jan 14, 2013
Company:

Hello Timofey Bugaevsky!
Thanks you for this example.

Edited: P& A - Dec 01, 2014 04:08 AM
 
#6
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Apr 26, 2016
Company:

Timofey Bugaevsky,
hello.
There is a problem with a Russian text when print QR code

I have a linux server with 1C server installed on it and 1C clients on Windows
So I print QR code, and there is an error when I try to read it

 
#7
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Alex Kas.

Could you please give more details on your problem?

 
#8
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Apr 26, 2016
Company:

Quote
Timofey Bugaevsky wrote:
Name

so I have a server ubuntu 14.04.4 LTS

1C 8.3.6.2449

windows 10 as a client

^это тест^Проверка кода^1234,234^ - this is the text that I try to put in QR-code

this is the result

 
#9
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello.

Maybe you need to use another encoding for your text. Try UTF-8.

 
#10
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Apr 26, 2016
Company:

I try to save a string with russian text in textdocument in utf-8, and then put text from the document in QRCodeData function. And this is don't solve the problem...

What else can I try?

 
#11
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Alex Kas!

I have updated the QR add-in. This should solve the problem on Linux. Please see the attachments.

Download qr.zip (397.2 KB)
 
#12
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Apr 26, 2016
Company:

Timofey Bugaevsky,
This version works fine.

thx!

 
Subscribe
Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.