Demo Application
Last updated
Last updated
The code example can be downloaded by clicking the file link below
This is a code example that fully incorporates the Sybrin Document Web SDK.
Then follow these steps:
Download the sybrin-document-websdk-demo-application.zip
file linked above
Extract the zip file contents
Open index.js
Follow JavaScript API and component configuration and initialization
Host the UI folder in any hostable environment, e.g. IIS
For your convenience in formulating custom styling for all components, sybrin.document.css
is also provided as a base example below.
<!DOCTYPE html>
<html class="" lang="en" id="html">
<head>
<title>
Sybrin Document
</title>
<base href="./" />
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<script src="sybrin.document.all.js"></script>
<script src="index.js"></script>
<link rel="stylesheet" href="index.css" media="screen" />
</head>
<body>
<header>
<div class="branding">
<img class="logo"
src="https://upload.wikimedia.org/wikipedia/commons/3/3e/Sybrin-Logo-Horizontal-Blue.svg" />
</div>
<div class="branding">
<span class="title">Sybrin Web SDK - Document</span>
</div>
<div class="actions">
</div>
</header>
<div id="viewport" class="viewport">
<div class="sybrin-demo-loading">
Please wait. Loading...
</div>
</div>
</body>
</html>
function detectIE() {
try {
var isIE = false || !!document.documentMode;
if (!isIE) {
if (navigator.userAgent.indexOf("MSIE") > 0) {
return true;
} else {
return false;
}
}
return true;
} catch(e) {
return true;
}
};
var isIE = detectIE();
if (isIE) {
alert('Browser not supported');
}
document.addEventListener('DOMContentLoaded', function (event) {
var sybrinDocument = new Sybrin.Document.Api();
var options = new Sybrin.Document.Options({
authToken: 'your-auth-token-here',
ocrEndpoint: 'your-ocr-endpoint-here'
});
sybrinDocument.initialize(options);
sybrinDocument.getVersionInfo().then(function(versionInfo) {
document.getElementsByClassName('title').item(0).innerHTML = 'Sybrin Web SDK - Document (version ' + versionInfo.webSdkVersion + ')';
});
sybrinDocument.checkCompatibility(true);
var currentComponent = null;
var initWizard = function() {
if (currentComponent) {
currentComponent.destroy();
}
currentComponent = new Sybrin.Document.WizardComponent({
id: 'viewport',
api: sybrinDocument
});
currentComponent.initialize();
currentComponent.onWizardDone = function(result) {
console.log(result);
}
currentComponent.onScanError = function(error) {
console.error(error);
}
currentComponent.onScanCancelled = function() {
console.log('Operation cancelled');
}
}
initWizard();
});
body {
font-family: Arial, Helvetica, sans-serif;
text-align: center;
background-color: #2d2d46;
margin: 0;
padding: 0;
}
header {
background-color: white;
margin-bottom: 24px;
padding: 15px 60px;
overflow: auto;
}
header .branding {
float: left;
}
header .actions {
float: right;
}
header img {
height: 33px;
padding-top: 3px;
}
header span.title {
display: inline-block;
line-height: 1;
border-radius: 50rem !important;
margin-left: 0.5rem !important;
padding: 0.5rem 1rem !important;
background: rgba(0, 0, 30, 0.05) !important;
color: rgba(0, 0, 30, 0.824) !important;
margin-top: 4px;
}
header button {
font: 300 1em / 2em Roboto, sans-serif;
padding: 0.25rem 1.5rem !important;
border-radius: 50rem !important;
border: none;
color: #fff !important;
background: linear-gradient(160deg, #00fafa 0, #3264fa 100%);
box-shadow: 0 15px 30px -10px #3264fa !important;
cursor: pointer;
}
.viewport {
border: 2px solid rgba(50, 50, 55, 0.2);
border-radius: 8px;
display: inline-block;
-webkit-box-shadow: 0 0 16px 8px rgba(50, 50, 55, 0.2);
box-shadow: 0 0 16px 8px rgba(50, 50, 55, 0.2);
width: 80%;
max-width: 1024px;
overflow: hidden;
}
.sybrin-demo-loading {
color: white;
padding: 20px;
}
.sybrin-debug-button {
-webkit-border-radius: 28;
-moz-border-radius: 28;
border-radius: 28px;
color: #3498db;
font-size: 16px;
font-weight: normal;
padding: 10px 27px;
text-decoration: none;
cursor: pointer;
background: #ffffff;
border: 1px solid;
}
@media screen and (max-width: 800px) {
header {
display: none;
}
}
@media screen and (max-width: 800px) {
header {
display: none;
}
.viewport {
width: calc(100% - 4px);
}
}
.sybrin-document-wizard {
position: relative;
width: 100%;
min-height: 342px;
margin: auto;
}
.sybrin-document-center {
text-align: center;
}
.sybrin-document-container {
position: relative;
padding: 12px;
width: 100%;
margin: auto;
background-color: white;
box-sizing: border-box;
border-radius: 8px;
}
.sybrin-document-halves {
display: flow-root;
}
.sybrin-document-half {
float: left;
width: 50%;
margin: 0;
text-align: center;
padding: 12px;
box-sizing: border-box;
}
.sybrin-document-half p {
margin-top: 0;
margin-bottom: 12px;
}
.sybrin-document-full {
width: 100%;
margin: 0;
text-align: center;
padding: 12px;
box-sizing: border-box;
}
.sybrin-document-full p {
margin-top: 0;
margin-bottom: 12px;
}
.sybrin-document-block {
border: 2px solid rgb(234, 234, 234);
border-radius: 8px;
width: 100%;
box-sizing: border-box;
text-align: center;
}
.sybrin-document-block-icon {
margin: 24px;
text-align: center;
}
.sybrin-document-block-icon svg {
height: 40px;
}
.sybrin-document-block-icon svg path {
stroke: inherit;
fill: inherit;
}
.sybrin-document-block-prompt {
margin: 24px;
}
.sybrin-document-block-button {
margin: 0 24px 24px 24px;
border: 2px solid rgb(234, 239, 253);
background-color: rgb(234, 239, 253);
border-radius: 8px;
color: rgb(53, 102, 247);
cursor: pointer;
padding: 16px;
}
.sybrin-document-component-section {
padding: 12px;
}
.sybrin-document-button-section {
text-align: right;
}
.sybrin-document-button-section .sybrin-document-flow-button {
margin: 12px;
}
.sybrin-document-align-left {
text-align: left;
}
.sybrin-document-flow-button {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
color: white;
font-weight: bold;
padding: 16px;
text-decoration: none;
text-align: center;
cursor: pointer;
background: rgb(53, 102, 247);
width: 224px;
border: 2px solid rgb(53, 102, 247);
}
.sybrin-document-flow-button.sybrin-secondary {
border: 2px solid rgb(234, 239, 253);
background-color: rgb(234, 239, 253);
color: rgb(53, 102, 247);
}
.sybrin-document-flow-button:disabled {
color: rgba(50, 50, 55, 0.4);
background: transparent;
border: 2px solid rgb(234, 234, 234);
}
.sybrin-document-list {
width: 100%;
max-width: 464px;
margin: auto;
padding: 16px;
background-color: rgb(244, 244, 244);
border-radius: 8px;
max-height: 448px;
overflow-y: auto;
overflow-x: hidden;
box-sizing: border-box;
border: 2px solid rgb(234, 234, 234);
}
.sybrin-document-card {
display: block;
height: 48px;
padding: 16px;
text-align: left;
border-radius: 8px;
cursor: pointer;
box-sizing: content-box;
}
.sybrin-document-card-image {
float: left;
height: 48px;
border-radius: 8px;
overflow: hidden;
}
.sybrin-document-card-image img {
height: 100%;
}
.sybrin-document-icon {
float: left;
width: 48px;
text-align: center;
}
.sybrin-document-icon svg {
height: 48px;
}
.sybrin-document-icon svg path {
stroke: inherit;
fill: inherit;
}
.sybrin-document-text {
float: left;
position: relative;
top: 50%;
transform: translateY(-50%);
margin-left: 24px;
}
.sybrin-document-card-title {
margin: 4px;
font-weight: bold;
}
.sybrin-document-card-subtitle {
margin: 4px;
}
.sybrin-document-selected {
background-color: rgb(53, 102, 247);
box-shadow: 0px 16px 32px #3264FA4D;
color: white;
}
.sybrin-document-selected .sybrin-document-icon svg path {
stroke: white;
fill: white;
}
.sybrin-document-video-container {
position: relative;
width: 100%;
z-index: 4;
margin: auto;
border: 8px solid rgb(53, 102, 247);
border-radius: 8px;
box-sizing: border-box;
}
.sybrin-document-video {
display: block;
width: 100%;
z-index: 4;
}
.sybrin-document-video-mirrored {
display: block;
width: 100%;
z-index: 4;
transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
}
.sybrin-document-prompt-container {
z-index: 100;
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding-top: 4px;
padding-bottom: 4px;
color: black;
text-align: center;
}
.sybrin-document-prompt-container-top {
top: 0;
}
.sybrin-document-prompt-container-bottom {
bottom: 0px;
}
.sybrin-document-prompt {
text-align: center;
color: black;
}
.sybrin-document-fullscreen-video-container {
position: fixed;
width: 100vw;
height: 100vh;
z-index: 3;
top: 0;
left: 0;
background-color: black;
}
.sybrin-document-result-fields {
width: 100%;
padding: 0 12px;
border-radius: 8px;
max-height: 344px;
overflow-y: auto;
overflow-x: hidden;
box-sizing: border-box;
}
.sybrin-document-result-group {
display: flow-root;
}
.sybrin-document-result-field {
width: calc(50% - 12px);
margin-bottom: 12px;
box-sizing: border-box;
}
.sybrin-document-result-fields textarea {
width: 100%;
margin-bottom: 12px;
box-sizing: border-box;
}
.sybrin-document-float-left {
float: left;
}
.sybrin-document-float-right {
float: right;
}
.sybrin-document-result-field div {
position: relative;
min-height: 45px;
}
.sybrin-document-result-field input {
height: 100%;
position: absolute;
top: 0;
left: 0;
width: 100%;
border: 2px solid rgb(53, 102, 247);
border-radius: 8px;
box-sizing: border-box;
padding-top: 16px;
padding-left: 16px;
}
.sybrin-document-result-field label {
position: absolute;
top: 6px;
left: 17px;
opacity: 0.5;
font-size: 11px;
}
.sybrin-document-result-image {
width: 100%;
border-radius: 8px;
overflow: hidden;
height: 230px;
background-color: black;
}
.sybrin-document-result-image-tall {
width: 100%;
border-radius: 8px;
overflow: hidden;
max-height: 460px;
background-color: black;
}
.sybrin-document-result-image img {
height: 100%;
display: block;
margin: auto;
max-width: 100%;
object-fit: contain;
}
.sybrin-document-result-image-tall img {
max-height: 460px;
display: block;
margin: auto;
max-width: 100%;
object-fit: contain;
}
.sybrin-document-fail-message {
padding: 12px;
color: #a8262b;
}
.sybrin-document-prompt-message {
padding: 12px;
}
.sybrin-mobile-capture-url {
word-break: break-all;
}
.sybrin-custom-scrollbar::-webkit-scrollbar-track
{
box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: rgb(244, 244, 244);
border-radius: 10px;
}
.sybrin-custom-scrollbar::-webkit-scrollbar
{
width: 10px;
background-color: rgb(244, 244, 244);
}
.sybrin-custom-scrollbar::-webkit-scrollbar-thumb
{
border-radius: 10px;
background-image: -webkit-gradient(linear,
left bottom,
left top,
color-stop(0.44, rgb(53, 102, 247)),
color-stop(0.72, rgb(53, 102, 247)),
color-stop(0.86, rgb(53, 102, 247)));
}
.sybrin-document-crop-element,
.sybrin-document-processing-result-element {
max-height: 600px;
max-width: 100%;
}
.sybrin-document-result-element {
max-height: 200px;
}
.sybrin-hidden {
display: none;
}
.sybrin-document-guideline-component {
text-align: center;
}
.sybrin-document-guideline-header {
margin: 16px 0;
}
.sybrin-document-guideline-container {
display: block;
}
.sybrin-document-guideline {
padding: 12px 8px;
margin: 0 12px 16px 12px;
}
.sybrin-document-guideline-icon {
float: left;
height: 25px;
width: 10%;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.sybrin-document-guideline-icon svg {
height: 100%;
}
.sybrin-document-guideline-text {
float: right;
text-align: left;
width: 85%;
position: relative;
top: 50%;
transform: translateY(-50%);
}
/* .sybrin-document-result-element {
max-width: 100%;
max-height: 100%;
} */
.sybrin-document-toolbar div {
width: 24px;
height: 24px;
display: inline-block;
border: 2px solid rgb(234, 239, 253);
background-color: rgb(234, 239, 253);
padding: 12px;
border-radius: 8px;
cursor: pointer;
box-sizing: content-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.sybrin-document-toolbar div svg {
stroke: rgb(53, 102, 247);
fill: rgb(53, 102, 247);
}
.sybrin-document-document-processing-component .sybrin-sdk-component-section {
max-width: 100%;
text-align: center;
margin: auto;
}
.sybrin-document-document-processing-component .area-selection-container,
.sybrin-document-document-processing-component .area-selection {
display: inline-block;
max-width: 100%;
}
.sybrin-document-toolbar svg {
max-height: 24px;
}
.area-selection-handle {
width: 22px !important;
height: 22px !important;
border-radius: 11px;
}
.area-selection-handle-nw {
left: -12px !important;
top: -12px !important;
}
.area-selection-handle-n {
margin-left: -12px !important;
top: -12px !important;
}
.area-selection-handle-ne {
right: -12px !important;
top: -12px !important;
}
.area-selection-handle-e {
margin-top: -12px !important;
right: -12px !important;
}
.area-selection-handle-se {
bottom: -12px !important;
right: -12px !important;
}
.area-selection-handle-s {
bottom: -12px !important;
margin-left: -12px !important;
}
.area-selection-handle-sw {
bottom: -12px !important;
left: -12px !important;
}
.area-selection-handle-w {
left: -12px !important;
margin-top: -12px !important;
}
.sybrin-document-loader-wrapper {
background-color: white;
z-index: 6;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
text-align: center;
}
.sybrin-document-loader {
display: inline-block;
width: 1rem;
height: 1rem;
vertical-align: text-bottom;
border: 0.2em solid currentColor;
border-right-color: transparent;
border-radius: 50%;
-webkit-animation-name: sybrin-document-loader;
animation-name: sybrin-document-loader;
-webkit-animation-duration: 0.75s;
animation-duration: 0.75s;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
position: relative;
top: 50%;
transform: translateY(-50%);
}
@-webkit-keyframes sybrin-document-loader {
0% {
-webkit-transform: translateY(-50%) rotate(0deg);
transform: translateY(-50%) rotate(0deg);
}
50% {
-webkit-transform: translateY(-50%) rotate(180deg);
transform: translateY(-50%) rotate(180deg);
}
100% {
-webkit-transform: translateY(-50%) rotate(360deg);
transform: translateY(-50%) rotate(360deg);
}
}
@keyframes sybrin-document-loader {
0% {
-webkit-transform: translateY(-50%) rotate(0deg);
transform: translateY(-50%) rotate(0deg);
}
50% {
-webkit-transform: translateY(-50%) rotate(180deg);
transform: translateY(-50%) rotate(180deg);
}
100% {
-webkit-transform: translateY(-50%) rotate(360deg);
transform: translateY(-50%) rotate(360deg);
}
}
.sybrin-document-modal-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.sybrin-document-modal-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 1000;
}
.sybrin-document-modal {
width: 100%;
max-width: 450px;
margin: auto;
position: relative;
top: 50%;
transform: translateY(-50%);
text-align: center;
}
.sybrin-document-modal-message {
background-color: white;
border-top: 2px solid rgb(234, 239, 253);
border-left: 2px solid rgb(234, 239, 253);
border-right: 2px solid rgb(234, 239, 253);
border-top-left-radius: 8px;
border-top-right-radius: 8px;
width: calc(100% - 48px);
padding: 24px;
}
.sybrin-document-modal-commands {
background-color: white;
border-bottom: 2px solid rgb(234, 239, 253);
border-left: 2px solid rgb(234, 239, 253);
border-right: 2px solid rgb(234, 239, 253);
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
padding: 0 0 24px 0;
width: 100%;
}
.sybrin-document-modal-commands button {
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
color: white;
font-weight: bold;
padding: 16px;
text-decoration: none;
text-align: center;
cursor: pointer;
background: rgb(53, 102, 247);
width: 224px;
border: 2px solid rgb(53, 102, 247);
}
.sybrin-document-flip-container {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 101;
perspective: 1000px;
}
.sybrin-document-flip-container .sybrin-document-flipper,
.sybrin-document-flip-container .sybrin-document-flipper {
transform: rotateY(180deg);
}
.sybrin-document-flip-front,
.sybrin-document-flip-back {
width: 100%;
height: 100%;
}
.sybrin-document-flip-front div {
width: 50%;
margin: auto;
position: relative;
top: 50%;
transform: perspective(1px) translateY(-50%);
}
.sybrin-document-flip-back div {
width: 50%;
margin: auto;
position: relative;
top: 50%;
transform: rotateY(180deg) perspective(1px) translateY(-50%);
}
.sybrin-document-flipper {
width: 100%;
height: 100%;
transition: 1s;
transform-style: preserve-3d;
position: relative;
}
.sybrin-document-flip-front, .sybrin-document-flip-back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.sybrin-document-flip-front {
z-index: 102;
transform: rotateY(0deg);
}
.sybrin-document-flip-back {
transform: rotateY(180deg);
}
.sybrin-document-processing-result-container,
.sybrin-document-processing-crop-container {
border: 2px solid rgb(91, 91, 95);
background: rgb(173, 173, 175);
margin: 0 12px !important;
}
@media screen and (max-width: 1060px) {
.sybrin-document-prompt-container {
padding-top: 2px;
padding-bottom: 2px;
font-size: 12px;
}
}
@media screen and (max-width: 960px) {
.sybrin-document-buttons-small .sybrin-document-flow-button {
width: 200px;
}
}
@media screen and (max-width: 800px) {
.sybrin-document-half {
float: none;
width: 100%;
float: left;
}
.sybrin-document-result-field {
width: 100%;
}
.sybrin-document-flow-button {
width: 198px;
}
}
@media screen and (max-width: 870px) {
.sybrin-document-buttons-small .sybrin-document-flow-button {
width: 180px;
}
}
@media screen and (max-height: 700px) {