I need to read file (.doc) then replace some data in doc and then send to print (doc or pdf).
At first step I try to read data from docs. From .txt its work, but from .doc no :(
I did example in jsfiddle http://jsfiddle.net/qo0fxo50/
I try to do it like:
<h1>Select file</h1>
<input type="file" on-read-file="showContent($fileContent)" />
<div>
<h2>File content is:</h2>
<pre>{{ contentfile }}</pre>
</div>
And directive (on-read-file):
directives.directive('onReadFile', function ($parse) {
return {
restrict: 'A',
scope: false,
link: function(scope, element, attrs) {
var fn = $parse(attrs.onReadFile);
element.on('change', function(onChangeEvent) {
var reader = new FileReader();
reader.readAsText((onChangeEvent.target).files[0], 'CP1251');
reader.onload = function(onLoadEvent) {
scope.$apply(function() {
fn(scope, {$fileContent:onLoadEvent.target.result});
});
};
});
}
};
});
I did example in jsfiddle http://jsfiddle.net/qo0fxo50/