| @@ -24,41 +24,41 @@ const DemoComponent1 = () => { | |||
| PDFEngine(); | |||
| 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 ( | |||
| <> | |||
| <div code="br-hide" style={{ display: 'flex', flexDirection: 'row', border: '1px solid #dedede', width: '50%', height: '200px', backgroundColor: 'white', padding: '5px', borderRadius: '10px' }}> | |||
| @@ -13,7 +13,7 @@ import { | |||
| CCallout | |||
| } from '@coreui/react'; | |||
| import CIcon from '@coreui/icons-react'; | |||
| import PDFEngine from 'PDFEngine'; | |||
| //import PDFEngine from 'PDFEngine'; | |||
| import MainChartExample from '../charts/MainChartExample.js'; | |||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | |||
| @@ -48,7 +48,7 @@ const DemoComponent10 = () => { | |||
| .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); | |||
| //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 | |||
| @@ -13,7 +13,7 @@ import { | |||
| CCallout | |||
| } from '@coreui/react'; | |||
| import CIcon from '@coreui/icons-react'; | |||
| import PDFEngine from 'PDFEngine'; | |||
| //import PDFEngine from 'PDFEngine'; | |||
| import MainChartExample from '../charts/MainChartExample.js'; | |||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | |||
| @@ -48,7 +48,7 @@ const DemoComponent12 = () => { | |||
| .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); | |||
| //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 | |||
| @@ -13,7 +13,7 @@ import { | |||
| CCallout | |||
| } from '@coreui/react'; | |||
| import CIcon from '@coreui/icons-react'; | |||
| import PDFEngine from 'PDFEngine'; | |||
| //import PDFEngine from 'PDFEngine'; | |||
| import MainChartExample from '../charts/MainChartExample.js'; | |||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | |||
| @@ -43,7 +43,7 @@ const DemoComponent7 = () => { | |||
| .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); | |||
| //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 | |||
| @@ -1,4 +1,4 @@ | |||
| import React, { lazy, useEffect, useState } from 'react'; | |||
| import React, { lazy, useState } from 'react'; | |||
| import { | |||
| CBadge, | |||
| CButton, | |||
| @@ -13,7 +13,7 @@ import { | |||
| CCallout | |||
| } from '@coreui/react'; | |||
| import CIcon from '@coreui/icons-react'; | |||
| import PDFEngine from 'PDFEngine'; | |||
| //import PDFEngine from 'PDFEngine'; | |||
| import MainChartExample from '../charts/MainChartExample.js'; | |||
| const WidgetsDropdown = lazy(() => import('../widgets/WidgetsDropdown.js')) | |||
| @@ -30,7 +30,7 @@ const DemoComponent9 = () => { | |||
| const handleChangeMargin = (event) => { | |||
| setMargins(event.target.value); | |||
| } | |||
| const exec = () => { | |||
| const query = []; | |||
| const arrayMargins = margins.split(','); | |||
| @@ -56,7 +56,7 @@ const DemoComponent9 = () => { | |||
| .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); | |||
| //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 | |||