PDF Reading
by deannorth
HTML
<script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-debug.js"></script>
<input type="file" id="file"/>
<table>
<thead>
<tr>
<th>Mark</th>
<th>Type</th>
<th>#</th>
<th># each</th>
<th>Length</th>
<th>Shape</th>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>Calculated Length</th>
</tr>
</thead>
<tbody data-bind="foreach: Items">
<tr data-bind="css:{warning: Math.abs(Tolerance()) > 25, danger: Math.abs(Tolerance()) > 60}">
<td><input type="text" data-bind="value: Mark" /></td>
<td><input type="text" data-bind="value: Type" /></td>
<td><input type="text" data-bind="value: Instances" /></td>
<td><input type="text" data-bind="value: Quantity" /></td>
<td><input type="text" data-bind="value: Length" /></td>
<td><input type="text" data-bind="value: ShapeCode" /></td>
<td><input type="text" data-bind="value: A" /></td>
<td><input type="text" data-bind="value: B" /></td>
<td><input type="text" data-bind="value: C" /></td>
<td><input type="text" data-bind="value: D" /></td>
<td><input type="text" data-bind="value: CalculateLength" /></td>
</tr>
</tbody>
</table>
CSS
input[type=text]{
width:30px;
}
.warning{
background:orange;
}
.danger{
background:red;
}
JavaScript
PDFJS.disableWorker = true;
function ViewModel(){
var self = this;
self.Items = ko.observableArray();
self.BarCodes = ['00','01','11','12', '13','14','15','21','22','23','24','25','26','27','28','29','31','32','33','34','35','36','41','44','46','47','51','56','63','64','67','75','77','98'];
self.Maths = {
'11': function(A,B,C,D,r,d){ return A + B - (0.5*r) - d;},
'12': function(A,B,C,D,r,d){ return A + B - (0.43*r) - (1.2*d);},
'13': function(A,B,C,D,r,d){ return A + (0.57*B) + C - (1.6*d);},
'14': function(A,B,C,D,r,d){ return A + C - (4*d);},
'15': function(A,B,C,D,r,d){ return A + C;},
'21': function(A,B,C,D,r,d){ return A + B + C - r - (2*d);},
'22': function(A,B,C,D,r,d){ return A + B + C + D - (1.5*r) - (3*d);},
'23': function(A,B,C,D,r,d){ return A + B + C - r - (2*d);},
'24': function(A,B,C,D,r,d){ return A + B + C;},
'25': function(A,B,C,D,r,d){ return A + B + E;},
'26': function(A,B,C,D,r,d){ return A + B + C;},
'27': function(A,B,C,D,r,d){ return A + B + C - (0.5*r) - d;},
'28': function(A,B,C,D,r,d){ return A + B + C - (0.5*r) - d;},
'29': function(A,B,C,D,r,d){ return A + B + C - r - (2*d);},
'31': function(A,B,C,D,r,d){ return A + B + C + D - (1.5*r) - (3*d);},
'32': function(A,B,C,D,r,d){ return A + B + C + D - (1.5*r) - (3*d);},
'33': function(A,B,C,D,r,d){ return (2*A) + (1.7*B) + (2*C) - (4*d);},
'34': function(A,B,C,D,r,d){ return A + B + C + E - (0.5*r) - d;},
'35': function(A,B,C,D,r,d){ return A + B + C + E - (0.5*r) - d;},
'36': function(A,B,C,D,r,d){ return A + B + C + D - r - (2*d);},
'41': function(A,B,C,D,r,d){ return A + B + C + D + E - (2*r) - (4*d);},
'44': function(A,B,C,D,r,d){ return A + B + C + D + E - (2*r) - (4*d);},
'46': function(A,B,C,D,r,d){ return A + (2*B) + C + E;},
'47': function(A,B,C,D,r,d){ return (2*A) + B + (2*C) - (1.5*r) - (3*d);},
'51': function(A,B,C,D,r,d){ return (2*(A + B + C)) - (2.5*r) - (5*d);},
'56': function(A,B,C,D,r,d){ return A + B + C +...