Commit b0833a79 authored by SergeyEzhin's avatar SergeyEzhin

Edit files script

parent c36d9d31
{ {
"parser": "babel-eslint", // "parser": "babel-eslint",
"extends": "eslint:recommended", // "extends": "eslint:recommended",
"globals": { // "globals": {
"require": true, // "require": true,
}, // },
"rules": { // "rules": {
"strict": 0 // "strict": 0
} // }
} }
...@@ -81,12 +81,15 @@ ...@@ -81,12 +81,15 @@
"webpack-stream": "^5.2.1" "webpack-stream": "^5.2.1"
}, },
"dependencies": { "dependencies": {
"@babel/polyfill": "^7.8.3",
"autosize": "^4.0.2", "autosize": "^4.0.2",
"axios": "^0.19.0", "axios": "^0.19.0",
"baron": "^3.0.3", "baron": "^3.0.3",
"choices.js": "^6.0.0", "choices.js": "^6.0.0",
"closest": "0.0.1", "closest": "0.0.1",
"html2canvas": "^1.0.0-rc.5",
"jquery": "^3.1.1", "jquery": "^3.1.1",
"jspdf": "^1.5.3",
"object-fit-images": "^3.2.3", "object-fit-images": "^3.2.3",
"svg4everybody": "^2.1.8", "svg4everybody": "^2.1.8",
"vee-validate": "^3.0.3", "vee-validate": "^3.0.3",
......
...@@ -6,3 +6,45 @@ ...@@ -6,3 +6,45 @@
// const $ = require('jquery'); // const $ = require('jquery');
// $( document ).ready(function() {}); // $( document ).ready(function() {});
import jsPDF from 'jspdf';
import "@babel/polyfill";
import html2canvas from "html2canvas";
let orderPdf = document.querySelector('#orderPdf');
let tableResult = document.querySelector('.table-responsive');
orderPdf.addEventListener('click', function(e)
{
e.preventDefault();
html2canvas(tableResult).then(function(canvas)
{
let pdfData = canvas.toDataURL('image/png');
let byteChars = btoa(pdfData);
let bytes = [];
console.log('File Size:', Math.round(byteChars.length / 1024), 'KB');
console.log(byteChars);
for (let i = 0; i < byteChars.length; i++)
bytes[i] = byteChars.charCodeAt(i);
let blob = new Blob([new Uint8Array(bytes)], {type: 'application/pdf'});
// создаём object URL из Blob
let downloadUrl = URL.createObjectURL(blob);
if(window.navigator && window.navigator.msSaveOrOpenBlob)
window.navigator.msSaveOrOpenBlob(blob);
else
{
let newWin = window.open(downloadUrl, '_blank', 'width=500,height=300,menubar=yes,scrollbars=yes,status=yes,resizable=yes');
newWin.focus();
newWin.print(); //чтобы эта строка сработала страница должна быть в сети, т.е. НЕ локально.
URL.revokeObjectURL(downloadUrl);
}
});
});
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment