|
@@ -46,7 +46,7 @@ export const watchScroll = (
|
|
|
};
|
|
|
|
|
|
const subscriber = fromEvent(element, 'scroll')
|
|
|
- .pipe(throttleTime(150), debounceTime(150))
|
|
|
+ .pipe(throttleTime(100), debounceTime(100))
|
|
|
.subscribe(debounceScroll);
|
|
|
|
|
|
state.subscriber = subscriber;
|
|
@@ -279,48 +279,27 @@ export const printPdf = async (url: string) => {
|
|
|
const printJS = require('print-js');
|
|
|
const isIE11 = !!(window.navigator && window.navigator.msSaveOrOpenBlob);
|
|
|
|
|
|
- await fetch(url, {
|
|
|
- headers: {
|
|
|
- 'Content-type': 'application/pdf',
|
|
|
- },
|
|
|
- })
|
|
|
- .then(data => data.blob())
|
|
|
- .then(res => {
|
|
|
- if (isIE11) {
|
|
|
- const wrapper = document.getElementById('embed-wrapper') as HTMLElement;
|
|
|
- wrapper.style.display = 'flex';
|
|
|
- const ele = document.createElement('embed');
|
|
|
- ele.setAttribute('type', 'application/pdf');
|
|
|
- ele.setAttribute('id', 'pdf-embed');
|
|
|
- ele.style.width = '70%';
|
|
|
- ele.style.height = '70%';
|
|
|
- ele.style.position = 'fixed';
|
|
|
- ele.style.top = '0';
|
|
|
- ele.style.left = '0';
|
|
|
- ele.style.bottom = '0';
|
|
|
- ele.style.right = '0';
|
|
|
- ele.style.margin = 'auto';
|
|
|
- ele.setAttribute('src', url);
|
|
|
- wrapper.appendChild(ele);
|
|
|
-
|
|
|
- printDocument('pdf-embed');
|
|
|
- } else {
|
|
|
- const fileReader = new FileReader();
|
|
|
- fileReader.readAsDataURL(res);
|
|
|
- fileReader.onload = fileLoadedEvent => {
|
|
|
- if (fileLoadedEvent.target) {
|
|
|
- const base64 = fileLoadedEvent.target.result as string;
|
|
|
-
|
|
|
- printJS({
|
|
|
- printable: base64.replace('data:application/pdf;base64,', ''),
|
|
|
- type: 'pdf',
|
|
|
- base64: true,
|
|
|
- showModal: true,
|
|
|
- });
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
- });
|
|
|
+ if (!isIE11) {
|
|
|
+ printJS(url);
|
|
|
+ } else {
|
|
|
+ const wrapper = document.getElementById('embed-wrapper') as HTMLElement;
|
|
|
+ wrapper.style.display = 'flex';
|
|
|
+ const ele = document.createElement('embed');
|
|
|
+ ele.setAttribute('type', 'application/pdf');
|
|
|
+ ele.setAttribute('id', 'pdf-embed');
|
|
|
+ ele.style.width = '70%';
|
|
|
+ ele.style.height = '70%';
|
|
|
+ ele.style.position = 'fixed';
|
|
|
+ ele.style.top = '0';
|
|
|
+ ele.style.left = '0';
|
|
|
+ ele.style.bottom = '0';
|
|
|
+ ele.style.right = '0';
|
|
|
+ ele.style.margin = 'auto';
|
|
|
+ ele.setAttribute('src', url);
|
|
|
+ wrapper.appendChild(ele);
|
|
|
+
|
|
|
+ printDocument('pdf-embed');
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
export const strip = (number: number): number => {
|