|
@@ -95,20 +95,21 @@ export const demoGetBASE64 = function (dataArray) {
|
|
return strData
|
|
return strData
|
|
}
|
|
}
|
|
|
|
|
|
-export const demoDownloadPDF = function (url) {
|
|
+export const demoDownloadPDF = function (data) {
|
|
- if (!(/^https?:/i.test(url))) return
|
|
+
|
|
- if (window.XMLHttpRequest) var xhr = new XMLHttpRequest(); else var xhr = new ActiveXObject('MSXML2.XMLHTTP')
|
|
+
|
|
- xhr.open('GET', url, false)
|
|
+
|
|
- if (xhr.overrideMimeType) {
|
|
+
|
|
- try {
|
|
+
|
|
- xhr.responseType = 'arraybuffer'
|
|
+
|
|
- var arrybuffer = true
|
|
+
|
|
- } catch (err) {
|
|
+
|
|
- xhr.overrideMimeType('text/plain; charset=x-user-defined')
|
|
+
|
|
- }
|
|
+
|
|
- }
|
|
+
|
|
- xhr.send(null)
|
|
+
|
|
- var data = xhr.response || xhr.responseBody
|
|
+
|
|
|
|
+ var arrybuffer = true
|
|
if (typeof Uint8Array !== 'undefined') {
|
|
if (typeof Uint8Array !== 'undefined') {
|
|
if (arrybuffer) var dataArray = new Uint8Array(data); else {
|
|
if (arrybuffer) var dataArray = new Uint8Array(data); else {
|
|
var dataArray = new Uint8Array(data.length)
|
|
var dataArray = new Uint8Array(data.length)
|
|
@@ -190,9 +191,9 @@ export const hdPrint = function (printerType, type, url, params, fileName, callb
|
|
}
|
|
}
|
|
|
|
|
|
if (type == 'preview') {
|
|
if (type == 'preview') {
|
|
- params.type = 'INK'
|
|
+
|
|
- params.printType = 'INK'
|
|
+
|
|
- printerType = 'INK'
|
|
+
|
|
}
|
|
}
|
|
url(params).then(res => {
|
|
url(params).then(res => {
|
|
console.log(res, type, printerType)
|
|
console.log(res, type, printerType)
|
|
@@ -247,9 +248,13 @@ export const jGPrint = function (data, type, printerType) {
|
|
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1)
|
|
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1)
|
|
|
|
|
|
if (type == 'preview') {
|
|
if (type == 'preview') {
|
|
- LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', data.data[data.data.length-1])
|
|
+ const reader = new FileReader()
|
|
- LODOP.SET_PRINT_PAGESIZE(3,2090,65,"");
|
|
+ reader.readAsDataURL(new Blob([data], { type: 'application/pdf' }))
|
|
- LODOP.PREVIEW()
|
|
+ reader.addEventListener('load', () => {
|
|
|
|
+ LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', reader.result.split('base64,')[1])
|
|
|
|
+ LODOP.SET_PRINT_PAGESIZE(3,2090,65,"");
|
|
|
|
+ LODOP.PREVIEW()
|
|
|
|
+ })
|
|
} else if (type == 'print') {
|
|
} else if (type == 'print') {
|
|
const dlen = data.data.length
|
|
const dlen = data.data.length
|
|
for(let i=0;i<dlen;i++){
|
|
for(let i=0;i<dlen;i++){
|