Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > QR code

Forum

Search UsersRules
QR code
#1
Active user
Points:: 0
Joined:: Jan 14, 2013

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

Profile
#2
Guest
Points::
Joined::

Hello, P& A.

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

Profile
#3
Active user
Points:: 0
Joined:: Jan 14, 2013

Hello, Timofey Bugaevsky!

Thanks!

Profile
#4
Guest
Points::
Joined::

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

Profile
#5
Active user
Points:: 0
Joined:: Jan 14, 2013

Hello Timofey Bugaevsky!
Thanks you for this example.

Profile
#6
Just came
Points:: 0
Joined:: Apr 26, 2016

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

Profile
#7
Guest
Points::
Joined::

Hello, Alex Kas.

Could you please give more details on your problem?

Profile
#8
Just came
Points:: 0
Joined:: Apr 26, 2016

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

Profile
#9
Guest
Points::
Joined::

Hello.

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

Profile
#10
Just came
Points:: 0
Joined:: Apr 26, 2016

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?

Profile
#11
Guest
Points::
Joined::

Hello, Alex Kas!

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

Profile
#12
Just came
Points:: 0
Joined:: Apr 26, 2016

Timofey Bugaevsky,
This version works fine.

thx!

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.