b‐PAC Applicat
[ Print from We
Brother Indu
© 2014 Brother Industries, Ltd. All Rights Reserved.
tion Examples
eb Application ]
ustries, Ltd.
Purpose and Target Customer
Purpose:
This document explains t
configuration and coding
labels from the web.
Target customer:
Developers who has know
programming.
© 2014 Brother Industries, Ltd. All Rights Reserved.
the system
g examples to print
wledge about web
(Reference) What is Web Application?
Application software which uses we
The functions will be active by show
from the server on the web browse
In this document, we explain about
application.
LAN
Web Server
© 2014 Brother Industries, Ltd. All Rights Reserved.
eb system.
w and run the HTML or script
er.
t how to print labels from web
N Web
Browser
Client PC
About Configuration Components
The solution ideas explained in this
labels.
Based on this, the following compo
system.
(1) b‐PAC (COM component)
(2) Windows PC to run b‐PAC
(3) Label printer which support b‐P
(4) Printer driver for the label print
The (2) Windows PC, you can choo
server side or in the web browser s
The (4) printer driver, it is necessary
to access it.
© 2014 Brother Industries, Ltd. All Rights Reserved.
s document use b‐PAC to print
onents are required in the
PAC
ter
ose if you install b‐PAC in the web
side.
y that the (2) Windows PC needs
System Configuration
System Configuration Requirement for Server La
#1 Installation An
Code execution CO
Printing labels from the printer Label Printer
connected to the server Only for Windows (ex
Ru
#2
Installation An
Printing labels from the printer Code execution CO
connected to the client PC Only for Windows
(Server generates the print (ex
command) Ru
#3a Especially not
Printing labels from client side script
#3b Especially not
Printing labels by using applet etc.
from client
© 2014 Brother Industries, Ltd. All Rights Reserved.
Development Requirement for Development
anguage for Server Client Language for Client
nything that can call Especially not
OM
x: C#, Java, PHP,
uby)
nything that can call Label Printer
OM
x: C#, Java, PHP,
uby)
Unrestricted Installation VBScript,
Unrestricted Code execution JScript
Label Printer (JavaScript N/A)
Only for Windows
Only for IE Anything that can
create ActiveX
Installation Control,
Code execution Java
Label Printer
Only for Windows
System Configuration #1
Printing labels from the printer connected to the
Printer driver and b-PAC are installed in the serv
In the server, any development language is fine i
the client.
LAN
Web Server Web Application
Call b-PAC
b-PAC
Printer Driver
Label Printer
© 2014 Brother Industries, Ltd. All Rights Reserved.
server.
ver. (Server OS is Windows only.)
if the language can call COM. No limitations for
N Web
Browser
Print Trigger
Client PC
System Configuration #1: Sample Code
ASP.NE
Example to use ASP.NET server.
Execute b‐PAC on the server.
Dim objDoc As bpac.DocumentClass = New
Try
objDoc.Open(strLbxPath)
objDoc.GetObject("txtName").Text = "w
objDoc.StartPrint("", bpac.PrintOptionC
objDoc.PrintOut(1, 0)
objDoc.EndPrint()
Catch ex As Exception
Me.lblErr.Text = “error" & vbTab & ex.M
End Try
objDoc.Close()
© 2014 Brother Industries, Ltd. All Rights Reserved.
e
ET(VB)
w bpac.DocumentClass
web print"
Constants.bpoDefault)
Message
System Configuration #2
Printing labels from the printer connected to the
Sharing the local printer so that it can be found f
LAN
Web Server Web Application
Call b-PAC
b-PAC Sha
Printer Driver
© 2014 Brother Industries, Ltd. All Rights Reserved.
client PC.
from the server side.
N Web
Browser
Print Trigger
Client PC
are
Printer Driver
Label Printer
System Configuration #2: Sample Code
ASP.NE
Example to use ASP.NET server.
Execute b‐PAC on the server.
Dim objDoc As bpac.DocumentClass = Ne
Try
objDoc.Open(strLbxPath)
objDoc.GetObject("txtName").Text = "w
objDoc.StartPrint("", bpac.PrintOptionC
objDoc.PrintOut(1, 0)
objDoc.EndPrint()
Catch ex As Exception
Me.lblErr.Text = “error" & vbTab & ex.M
End Try
objDoc.Close()
© 2014 Brother Industries, Ltd. All Rights Reserved.
e
ET(VB)
ew bpac.DocumentClass
web print"
Constants.bpoDefault)
Message
System Configuration #3a
Printing labels from the printer connected to the
Installing b-PAC SDK in the client PC (Windows
VBScript or JScript only, Internet Explorer only.
LAN
Web Server
© 2014 Brother Industries, Ltd. All Rights Reserved.
client PC
only)
Print Trigger
N Web
Browser
Script
Client PC
Call b-PAC
b-PAC
Printer Driver
Label Printer
System Configuration #3a: Sample Cod
ASP.NE
Example to use ASP.NET server. Execute b‐PAC on the
Dim stbScript As New StringBuilder
With stbScript
.Append("<script type=""text/vbscript"" charset="
.Append("sub window_onload()" & vbCrLf)
.Append("Set objDoc = CreateObject(""bpac.Docum
.Append("If (objDoc.Open(""" & strLbxPath & """)
.Append("objDoc.GetObject(""Name"").Text = """ &
.Append("objDoc.StartPrint """", 0" & vbCrLf)
.Append("objDoc.PrintOut 1, 0" & vbCrLf)
.Append("objDoc.EndPrint()" & vbCrLf)
.Append("objDoc.Close() " & vbCrLf)
.Append("End If " & vbCrLf)
.Append("Set objDoc = Nothing" & vbCrLf)
.Append("end sub" & vbCrLf)
.Append("</script>" & vbCrLf)
End With
ClientScript.RegisterStartupScript(Me.GetType(), "Sam
© 2014 Brother Industries, Ltd. All Rights Reserved.
de
ET(VB)
e client side.
""Shift_JIS"">" & vbCrLf)
ment"")" & vbCrLf)
<> False) Then" & vbCrLf)
& strNamae & """" & vbCrLf)
mple", stbScript.ToString, False)
System Configuration #3a: Sample Cod
Exam
HTML sample to display on the Internet Explorer ins
Enable to print labels by using b‐PAC by displaying t
<html>
<head>
<title>Asset Labelling</title>
<script LANGUAGE="VBScript">
<!–‐
Sub DoPrint(strExport)
Dim TheForm
Set TheForm = Document.ValidForm
Dim ObjDoc
Set ObjDoc CreateObject("bpac.Document")
strDir = “where the *.LBX file exists"
bRet = ObjDoc.Open(strDir & “Asset Label.lbx")
If ( bRet <> False ) Then
© 2014 Brother Industries, Ltd. All Rights Reserved.
de
mple
stalled in the client PC
the HTML like this on the Internet Explorer.
System Configuration #3a: Sample Cod
Example (c
ObjDoc.GetObject("Name").Text = TheForm.FixedA
ObjDoc.StartPrint "DocumentName",bpoAutoCut
ObjDoc.PrintOut 1, bpoAutoCut
ObjDoc.EndPrint
End If
Set ObjDoc = Nothing
End Sub
‐‐>
</script>
</head>
<body>
<form NAME="ValidForm">
Asset Name:<INPUT VALUE="" NAME=“FixedAsset" S
<input TYPE="button" VALUE=“print" onClick='DoPrin
</form>
</body>
</html>
© 2014 Brother Industries, Ltd. All Rights Reserved.
de
continued)
Asset.Value
SIZE=30><br>
nt'>
System Configuration #3b
In case you want to use the web browser other th
Possible to call b-PAC by using Java Applet or Ac
Web Server LAN
Download
© 2014 Brother Industries, Ltd. All Rights Reserved.
han IE
ctiveX (Windows only)
Print Trigger
N Web
Browser
Applet or ActiveX
Call b-PAC Client PC
b-PAC
Printer Driver
Label Printer
System Configuration #3b
Call b‐PAC by using Java Applet or ActiveX Control
Objects to be defined on HTML by using Object tag
About Silverlight
Possible to execute outside of web browser (Silverl
© 2014 Brother Industries, Ltd. All Rights Reserved.
etc. (being downloaded from the web server)
light 4 or later)