Commit 061a935f by firesong1337

export Pdf

parent 8eebaef0
......@@ -18,7 +18,7 @@
}
},
"..": {
"version": "1.0.27",
"version": "1.0.29",
"license": "MIT",
"dependencies": {
"@tiptap/core": "^2.0.0-beta.176",
......
......@@ -39,6 +39,7 @@ import IframeCustomModal from './modals/IframeCustomModal'
import { isMobile } from 'react-device-detect'
import Resizable from './extensions/Resizing'
import Resizing from "./extensions/Resizing";
import { ExportPdf } from './extensions/ExportPdf'
const initialBubbleItems = [
'bold',
......@@ -195,6 +196,10 @@ const QEditor = ({
title: 'Вставить презентацию pdf',
onClick: () => modalOpener('iframe_pdf', 'Вставить презентацию pdf')
},
export_pdf: {
title: 'Экспорт в pdf',
onClick: () => ExportPdf()
},
audio: {
title: 'Вставить аудио файл',
onClick: () => modalOpener('audio', 'Вставить аудио файл')
......
......@@ -86,7 +86,8 @@ const toolsInit = {
items: [
'voicemessage',
'webcamera',
'screencust'
'screencust',
'export_pdf',
]
},
],
......
//import html2pdf from 'html2pdf.js'
export const ExportPdf = () => {
let now = new Date();
//let date = (now.getDate() < 10 ? '0' + now.getDate() : now.getDate()) + '.' + (now.getMonth() < 10 ? '0' + now.getMonth() : now.getMonth()) + '.' + now.getFullYear() + ' ' + (now.getHours() < 10 ? '0' + now.getHours() : now.getHours()) + ':' + (now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes());
let date = formatDateTime(now)
/*
let preHtml = "<html><head><meta charset='utf-8'><title>Export HTML To Doc</title></head><body>";
preHtml += "<div style={{margin: '0 0 0 35px'}}>\n" +
"<br /><div style={{fontSize:'25px', textAlign: 'right'}}>Дата формирования " + date + "</div><br /><br />\n"
let postHtml = "</body></html>";
let html = preHtml + document.querySelector('.atma-editor-content').innerHTML + postHtml;
let blob = new Blob([html], {
type: 'application/pdf'
//type: 'text/plain'
});
*/
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
mywindow.document.write('<html><head><title>' + "Export HTML To Pdf" + '</title>');
mywindow.document.write('</head><body >');
mywindow.document.write('<h1>' + date + '</h1>');
mywindow.document.write(document.querySelector('.atma-editor-content').innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
function formatDateTime(date) {
// Создаем объект Intl.DateTimeFormat с нужными опциями
const formatter = new Intl.DateTimeFormat('ru-RU', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
});
// Форматируем дату
const formattedDate = formatter.format(date);
return formattedDate;
}
/*
console.log(blob)
// Specify link url
//let url = 'data:application/pdf;charset=utf-8,' + URL.createObjectURL(blob)
let url = 'base64,'+ URL.createObjectURL(blob);
//let url = 'data:application/pdf;base64,' + URL.createObjectURL(blob)
console.log(url)
// Specify file name
let filename = now.getTime() + '.pdf';
// Create download link element
let downloadLink = document.createElement("a");
document.body.appendChild(downloadLink);
if (navigator.msSaveOrOpenBlob) {
navigator.msSaveOrOpenBlob(blob, filename);
} else {
// Create a link to the file
downloadLink.href = url;
// Setting the file name
downloadLink.download = filename;
//triggering the function
downloadLink.click();
}
document.body.removeChild(downloadLink);*/
}
\ No newline at end of file
......@@ -902,6 +902,13 @@ body{
height: 20px;
margin-top: 4px;
}
&.qexport_pdf{
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAACG0lEQVR4nO2Zuy4FQRjHf+dEKLU6HoCOB9A6Sl5AoqciKhEkoqCiQTwEDQq3RtDzAjQuIYR1ycokc5LJZHfNnJ2Zs4f9ki9rze3/2/nmO5MZKK200kysDZgGLoAIiKV/AHNa3UXgU6mT5jdAlUDijzKEPGr1XwzE130zBMR0hoA8MxAM4lIZTMC05+wvCWLLJ4Qa83nFkzETW74g1EFc97ceAsInQCUEhE8AQkC4BlDXVGcICNcA5xYp9raIAEMWAHERAYTVgDMtnFoKIOiYcQlgb3E5A38hhHqAA8uU58P3ge5GAIogPlYgrM0kR4fyqFVi36mG3xoPA+/KFzoFBrSyL+AamJAbNr1dLP+uNQNgNmGqH4CulLLllHbvcn/UNADx7AB25Pu4UrYAjEiR30Cf1s50HUYhAHYTAOoiN+X7ZMIMnGRoECccb/LpDUD1ey2ETACOGxHnGiCSX7JfKxNfblQJoV7LEMplNiGUVqb6kkE73RblSZ9YS84BROp7SskgNSWNXgFjhu3SFrHo6//9kEWBtwufCdkmF0AzNnMvLgHEFnavlWegCGshLgFwf7wefAYulE5mPEIsAK/AqnImqgNUZbmoN+/iiqlRvwMGM+7WNqRYtU1V/r/+/mxzyXfoAWJbG2dVK9/45V3UxwZiSp4sR55moAKsFel2sxGrGEAUVrwJROHFIy0JomXE102IXZHZSTwTxf8AZpagqyQ5vmsAAAAASUVORK5CYII=');
background-size: contain;
width: 28px;
height: 20px;
margin-top: 4px;
}
&.qclearMarks{
background-image: url('data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%2215%22%20height%3D%2215%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M8.574%206.094%207.07%204.609l.47-1.093H5.995L3.965%201.484h9.355c.274%200%20.505.095.694.284.188.188.283.42.283.693a.943.943%200%200%201-.283.693.943.943%200%200%201-.694.284H9.707L8.574%206.094zm5.43%208.73L7.598%208.398l-1.465%203.438a.935.935%200%200%201-.362.43.976.976%200%200%201-.537.156.932.932%200%200%201-.82-.44.913.913%200%200%201-.078-.927l1.758-4.14L.176.995A.562.562%200%200%201%200%20.586C0%20.43.059.293.176.176A.562.562%200%200%201%20.586%200c.156%200%20.293.059.41.176l13.828%2013.828a.562.562%200%200%201%20.176.41.562.562%200%200%201-.176.41.562.562%200%200%201-.41.176.562.562%200%200%201-.41-.176z%22%20fill%3D%22%231D1D1F%22%20fill-rule%3D%22nonzero%22%2F%3E%3C%2Fsvg%3E');
}
......
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