Little working pdfs integration

This commit is contained in:
Johannes Zillmann 2016-11-12 00:31:06 +01:00
parent d20347f70f
commit a4a3d08222
2 changed files with 14 additions and 0 deletions

View File

@ -19,6 +19,7 @@
"url": "https://github.com/jzillmann/pdf-to-markdown"
},
"dependencies": {
"pdfjs-dist": "^1.6.317",
"vue": "^2.0.5"
},
"devDependencies": {

View File

@ -14,6 +14,7 @@
</template>
<script>
import pdfjs from 'pdfjs-dist';
export default {
props : {
multiple : {
@ -58,6 +59,18 @@ export default {
var files = e.target.files || e.dataTransfer.files;
console.debug(files);
if (!files.length) return;
var reader = new FileReader();
reader.onload = (evt) => {
console.debug("Loaded");
var buffer = evt.target.result;
PDFJS.getDocument(buffer).then(function (pdfDocument) {
console.log('Number of pages: ' + pdfDocument.numPages);
});
};
reader.readAsDataURL(files[0]);
this.createImage(files[0]);
},
createImage(file) {