0% found this document useful (0 votes)
22 views

Browserprinting

The document provides instructions for printing content from a website to a Bluetooth thermal printer using a Bluetooth Print app. It explains how to add a print button to a webpage that will launch the app and send JSON print data from a response URL when clicked. Sample request and response files are included to demonstrate setting up text, image, barcode, and QR code print entries in JSON format.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Browserprinting

The document provides instructions for printing content from a website to a Bluetooth thermal printer using a Bluetooth Print app. It explains how to add a print button to a webpage that will launch the app and send JSON print data from a response URL when clicked. Sample request and response files are included to demonstrate setting up text, image, barcode, and QR code print entries in JSON format.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Following is the instructions to print content on your Bluetooth Thermal Printer

from your own website using Bluetooth Print app


Bluetooth Print App: https://play.google.com/store/apps/details?
id=mate.bluetoothprint

You can print from your webpage (localhost or website) through any android browser.
It means that you just need to open your website from any android browser and
clinking a button on your website will send print command to Bluetooth print app
provided that you install small program into your web page
Instructions: - Enable Browser Print function in the app first
- Put following HTML link on your request webpage
<a href="my.bluetoothprint.scheme://<RESPONSEURL>">Print</a>
where <RESPONSEURL> is your response URL
e.g. <a href="my.bluetoothprint.scheme://http://www.mydomain.com/response.php?
id=45">Print</a>
The response page must have data to print in JSON format
Now when you open your webpage with any android browser and click on button click
me using above method, android browser will launch Bluetooth print app installed on
device which will then try to access response URL i.e.
http://www.mydomain.com/response.php?id=45 and it will print data as shown in JSON
Select any action from list below\n To download sample response file, click
Response button below

Note: If you are trying to access from localhost, make sure that you can access
localhost page in your browser. You can find several help tutorials for this.
Below are sample request file program and response file program. You need to open
request file in Chrome browser and on print button click, app will try to access
JSON content in response page and print that content.

<!------------------------ Below is sample request file program (request.html)


-------------------------->
<html>
<head>
</head>
<body>
<a href="my.bluetoothprint.scheme://http://192.168.43.160/response.php">localhost
print</a>
<a href="my.bluetoothprint.scheme://https://www.matetech.in/myfiles/temp/
response.php">webpage print</a>
</body>
</html>

<!------------------------ Below is sample response file program in PHP


(response.php) --------------------------->
<?php
//you can print text, image, barcode and QR code by sending request from your
website. You just need to send data in JSON format
$a = array();
//sending text entry
$obj1 = (object) $a;
$obj1->type = 0;//text
$obj1->content = 'My Title';//any string
$obj1->bold = 1;//0 if no, 1 if yes
$obj1->align =2;//0 if left, 1 if center, 2 if right
$obj1->format = 3;//0 if normal, 1 if double Height, 2 if double Height + Width, 3
if double Width, 4 if small
array_push($a,$obj1);
//sending image entry
$obj2 = (object) $a;
$obj2->type = 1;//image
$obj2->path = 'https://www.mydomain.com/myimage.jpg';//complete filepath on your
web server; make sure that it is not big size
$obj2->align = 2;//0 if left, 1 if center, 2 if right; set left align for big size
images
array_push($a,$obj2);
//sending barcode entry
$obj3 = (object) $a;
$obj3->type = 2;//barcode
$obj3->value = '1234567890123';//valid barcode value
$obj3->width = 100;//valid barcode width
$obj3->height = 50;//valid barcode height
$obj3->align = 0;//0 if left, 1 if center, 2 if right
array_push($a,$obj3);
//sending QR entry
$obj4 = (object) $a;
$obj4->type = 3;//QR code
$obj4->value = 'sample qr text';//valid QR code value
$obj4->size = 40;//valid QR code size in mm
$obj4->align = 2;//0 if left, 1 if center, 2 if right
array_push($a,$obj4);

$obj5 = (object) $a;


$obj5->type = 0;//text
$obj5->content = ' ';//empty line
$obj5->bold = 0;
$obj5->align = 0;
array_push($a,$obj5);

$obj6 = (object) $a;


$obj6->type = 0;//text
$obj6->content = 'This text has<br />two lines';//multiple lines text
$obj6->bold = 0;
$obj6->align = 0;
array_push($a,$obj6);

echo json_encode($a,JSON_FORCE_OBJECT);
//Note that same sequence will be used for printing content
?>

You might also like