| PDFEngine(); | PDFEngine(); | ||||
| window.print(); | window.print(); | ||||
| } | } | ||||
| const apiCall = () => { | |||||
| // const apiCall = () => { | |||||
| const url = encodeURIComponent("http://localhost:3000/#/DemoComponent2"); | |||||
| const dateNow = new Date(); | |||||
| fetch('https://localhost:7285/api/PDFGenerator/' + url) | |||||
| .then(async res => ({ | |||||
| filename: "John Doe - " + dateNow +" - report.pdf", | |||||
| blob: await res.blob() | |||||
| })) | |||||
| .then(resObj => { | |||||
| // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | |||||
| const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | |||||
| //const bytes = new Uint8Array(newBlob); | |||||
| //console.log(bytes); | |||||
| //modifyPdf(bytes); | |||||
| // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob | |||||
| if (window.navigator && window.navigator.msSaveOrOpenBlob) { | |||||
| window.navigator.msSaveOrOpenBlob(newBlob); | |||||
| } else { | |||||
| // For other browsers: create a link pointing to the ObjectURL containing the blob. | |||||
| const objUrl = window.URL.createObjectURL(newBlob); | |||||
| // const url = encodeURIComponent("http://localhost:3000/#/DemoComponent2"); | |||||
| // const dateNow = new Date(); | |||||
| // fetch('https://localhost:7285/api/PDFGenerator/' + url) | |||||
| // .then(async res => ({ | |||||
| // filename: "John Doe - " + dateNow +" - report.pdf", | |||||
| // blob: await res.blob() | |||||
| // })) | |||||
| // .then(resObj => { | |||||
| // // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | |||||
| // const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | |||||
| // //const bytes = new Uint8Array(newBlob); | |||||
| // //console.log(bytes); | |||||
| // //modifyPdf(bytes); | |||||
| // // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob | |||||
| // if (window.navigator && window.navigator.msSaveOrOpenBlob) { | |||||
| // window.navigator.msSaveOrOpenBlob(newBlob); | |||||
| // } else { | |||||
| // // For other browsers: create a link pointing to the ObjectURL containing the blob. | |||||
| // const objUrl = window.URL.createObjectURL(newBlob); | |||||
| let link = document.createElement('a'); | |||||
| link.href = objUrl; | |||||
| link.download = resObj.filename; | |||||
| link.click(); | |||||
| // let link = document.createElement('a'); | |||||
| // link.href = objUrl; | |||||
| // link.download = resObj.filename; | |||||
| // link.click(); | |||||
| // For Firefox it is necessary to delay revoking the ObjectURL. | |||||
| setTimeout(() => { window.URL.revokeObjectURL(objUrl); }, 250); | |||||
| } | |||||
| }) | |||||
| .catch((error) => { | |||||
| console.log('DOWNLOAD ERROR', error); | |||||
| }); | |||||
| } | |||||
| // // For Firefox it is necessary to delay revoking the ObjectURL. | |||||
| // setTimeout(() => { window.URL.revokeObjectURL(objUrl); }, 250); | |||||
| // } | |||||
| // }) | |||||
| // .catch((error) => { | |||||
| // console.log('DOWNLOAD ERROR', error); | |||||
| // }); | |||||
| // } | |||||
| return ( | return ( | ||||
| <> | <> | ||||
| <div code="br-hide" style={{ display: 'flex', flexDirection: 'row', border: '1px solid #dedede', width: '50%', height: '200px', backgroundColor: 'white', padding: '5px', borderRadius: '10px' }}> | <div code="br-hide" style={{ display: 'flex', flexDirection: 'row', border: '1px solid #dedede', width: '50%', height: '200px', backgroundColor: 'white', padding: '5px', borderRadius: '10px' }}> |
| CCallout | CCallout | ||||
| } from '@coreui/react'; | } from '@coreui/react'; | ||||
| import CIcon from '@coreui/icons-react'; | import CIcon from '@coreui/icons-react'; | ||||
| import PDFEngine from 'PDFEngine'; | |||||
| //import PDFEngine from 'PDFEngine'; | |||||
| import MainChartExample from '../charts/MainChartExample.js'; | import MainChartExample from '../charts/MainChartExample.js'; | ||||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | ||||
| .then(resObj => { | .then(resObj => { | ||||
| // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | ||||
| const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | ||||
| const bytes = new Uint8Array(newBlob); | |||||
| //const bytes = new Uint8Array(newBlob); | |||||
| //console.log(bytes); | //console.log(bytes); | ||||
| //modifyPdf(bytes); | //modifyPdf(bytes); | ||||
| // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob | // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob |
| CCallout | CCallout | ||||
| } from '@coreui/react'; | } from '@coreui/react'; | ||||
| import CIcon from '@coreui/icons-react'; | import CIcon from '@coreui/icons-react'; | ||||
| import PDFEngine from 'PDFEngine'; | |||||
| //import PDFEngine from 'PDFEngine'; | |||||
| import MainChartExample from '../charts/MainChartExample.js'; | import MainChartExample from '../charts/MainChartExample.js'; | ||||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | ||||
| .then(resObj => { | .then(resObj => { | ||||
| // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | ||||
| const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | ||||
| const bytes = new Uint8Array(newBlob); | |||||
| //const bytes = new Uint8Array(newBlob); | |||||
| //console.log(bytes); | //console.log(bytes); | ||||
| //modifyPdf(bytes); | //modifyPdf(bytes); | ||||
| // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob | // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob |
| CCallout | CCallout | ||||
| } from '@coreui/react'; | } from '@coreui/react'; | ||||
| import CIcon from '@coreui/icons-react'; | import CIcon from '@coreui/icons-react'; | ||||
| import PDFEngine from 'PDFEngine'; | |||||
| //import PDFEngine from 'PDFEngine'; | |||||
| import MainChartExample from '../charts/MainChartExample.js'; | import MainChartExample from '../charts/MainChartExample.js'; | ||||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | ||||
| .then(resObj => { | .then(resObj => { | ||||
| // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | ||||
| const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | ||||
| const bytes = new Uint8Array(newBlob); | |||||
| //const bytes = new Uint8Array(newBlob); | |||||
| //console.log(bytes); | //console.log(bytes); | ||||
| //modifyPdf(bytes); | //modifyPdf(bytes); | ||||
| // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob | // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob |
| import React, { lazy, useEffect, useState } from 'react'; | |||||
| import React, { lazy, useState } from 'react'; | |||||
| import { | import { | ||||
| CBadge, | CBadge, | ||||
| CButton, | CButton, | ||||
| CCallout | CCallout | ||||
| } from '@coreui/react'; | } from '@coreui/react'; | ||||
| import CIcon from '@coreui/icons-react'; | import CIcon from '@coreui/icons-react'; | ||||
| import PDFEngine from 'PDFEngine'; | |||||
| //import PDFEngine from 'PDFEngine'; | |||||
| import MainChartExample from '../charts/MainChartExample.js'; | import MainChartExample from '../charts/MainChartExample.js'; | ||||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | ||||
| const handleChangeMargin = (event) => { | const handleChangeMargin = (event) => { | ||||
| setMargins(event.target.value); | setMargins(event.target.value); | ||||
| } | } | ||||
| const exec = () => { | const exec = () => { | ||||
| const query = []; | const query = []; | ||||
| const arrayMargins = margins.split(','); | const arrayMargins = margins.split(','); | ||||
| .then(resObj => { | .then(resObj => { | ||||
| // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | // It is necessary to create a new blob object with mime-type explicitly set for all browsers except Chrome, but it works for Chrome too. | ||||
| const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | const newBlob = new Blob([resObj.blob], { type: 'application/pdf' }); | ||||
| const bytes = new Uint8Array(newBlob); | |||||
| //const bytes = new Uint8Array(newBlob); | |||||
| //console.log(bytes); | //console.log(bytes); | ||||
| //modifyPdf(bytes); | //modifyPdf(bytes); | ||||
| // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob | // MS Edge and IE don't allow using a blob object directly as link href, instead it is necessary to use msSaveOrOpenBlob |