1、mammo(word.docx)
Var URL=URL
var xhr=new XMLHttpRequest();
Xhr。open('get ',url,true);
X='水滴';
//添加請(qǐng)求標(biāo)頭
//從cookie獲取令牌
X ('access-token ',get cookie(' access-t oken '));
Xhr。onload=function ({
If atus==200){
var blob=;
//讀取流
readfileinputeventasarraybuffer(blob);
$('#wordJS ')。show();
}
}
x();
Function displayResult (result) {
//讀取的blob格式副本將被分配html值
Let html=result。value
Let newHTML=(//g,'')
.replace('h1 ',' h1 ')
.replace( /table/g,' table ')
.replace(/tr/g,' tr ')
.replace( /td/g,' td ')
.replace(/p/g,' p ');
document . getelementbyid(' word output ')。innerhtml=newhtml
}
function readfileinputeventasarraybuffer(excel blob){
Var reader=new FileReader(:)
Reader.onload=function(加載事件){
var array buffer=load event . target . result;
Try{
請(qǐng)讀取//
mamoth . converttohtml({ arraybuffer 3360 arraybuffer })。then (displayresult)。done();
}catch(err) {
Con(“格式不正確!”);
}
reader . reada sarr ay buffer(excel b 1 ob);
}
2、xl(excel.xlsx)
//url文件地址
Var URL=URL
var xhr=new XMLHttpRequest();
X('get ',url,true);
X='水滴';
//添加請(qǐng)求標(biāo)頭
X ('access-token ',get cookie(' access-token '));
X=function () {
If atus==200) {
var blob=;
readfileinputeventasarraybuffer(blob);
}
}
x();
function readfileinputeventasarraybuffer(文件){
const reader=new file reader();
Reader.readasbinarystring(文件);
Reader.onload=(e)={
Constdata=e
constzz excel=window . xlsx . read(data,{ type 3360 ' binary ' });
const result=[];
for(let I=0;I zzexcel。s;I) {
const new data=window . xlsx . u[ZZ excel . sheet names[I]]);
Re(.newData)
}
//儲(chǔ)存資料,并將excel讀取為陣列
DataExcel=result
}
}3,(嵌入)
!Function(根、工廠){
Function'==typeof define de?Define ([],工廠): ' object '==type of module modul
e.exports ? module.exports = factory() : root.PDFObject = factory() }(this, function() { "use strict"; if ("undefined" == typeof window || void 0 === window.navigator || void 0 === window.naviga || void 0 === window.naviga) return !1; let nav = window.navigator , ua = window.naviga , isIE = "ActiveXObject"in window , isModernBrowser = void 0 !== window.Promise , supportsPdfMimeType = void 0 !== nav.mimeTypes["application/pdf"] , isMobileDevice = void 0 !== nav.platform && "MacIntel" === nav.platform && void 0 !== nav.maxTouchPoints && nav.maxTouchPoints > 1 || /Mobi|Tablet|Android|iPad|iPhone/.test(ua) , isSafariDesktop = !isMobileDevice && void 0 !== nav.vendor && /Apple/.te) && /Safari/.test(ua) , isFirefoxWithPDFJS = !!(!isMobileDevice && /irefox/.test(ua) && ua.split("rv:").length > 1) && parseIn("rv:")[1].split(".")[0], 10) > 18 , createAXO = function(type) { var ax; try { ax = new ActiveXObject(type) } catch (e) { ax = null } return ax } , supportsPDFs = !isMobileDevice && (isModernBrowser || isFirefoxWithPDFJS || supportsPdfMimeType || isIE && !(!createAXO("AcroPDF.PDF") && !createAXO("PDF.PdfCtrl"))) , embedError = function(msg, suppressConsole) { return suppressConsole || con("[PDFObject] " + msg), !1 } , emptyNodeContents = function(node) { for (; node.firstChild; ) node.removeChild) } , generatePDFJSMarkup = function(targetNode, url, pdfOpenFragment, PDFJS_URL, id, title, omitInlineStyles) { emptyNodeContents(targetNode); let fullURL = PDFJS_URL + "?file=" + encodeURIComponent(url) + pdfOpenFragment , div = document.createElement("div") , iframe = document.createElement("iframe"); return i = fullURL, i = "pdfobject", i = "application/pdf", i = "0", i = "fullscreen", i = title, id && = id), omitInlineStyles || = "position: absolute; top: 0; right: 0; bottom: 0; left: 0;", i = "border: none; width: 100%; height: 100%;", = "relative", = "auto"), div.appendChild(iframe), (div), ("pdfobject-container"), ("iframe")[0] } , embed = function(url, targetSelector, options) { let selector = targetSelector || !1 , opt = options || {} , id = "string" == typeof o ? o : "" , page = o || !1 , pdfOpenParams = o || {} , fallbackLink = o || !0 , width = o || "100%" , height = o || "100%" , title = o || "Embedded PDF" , assumptionMode = "boolean" != typeof o || o , forcePDFJS = "boolean" == typeof o && o , supportRedirect = "boolean" == typeof o && o , omitInlineStyles = "boolean" == typeof o && o , suppressConsole = "boolean" == typeof o && o , forceIframe = "boolean" == typeof o && o , PDFJS_URL = o || !1 , targetNode = function(targetSelector) { let targetNode = document.body; return "string" == typeof targetSelector ? targetNode = document.querySelector(targetSelector) : void 0 !== window.jQuery && targetSelector instanceof jQuery && ? targetNode = (0) : void 0 !== && 1 === && (targetNode = targetSelector), targetNode }(selector) , fallbackHTML = "" , pdfOpenFragment = ""; if ("string" != typeof url) return embedError("URL is not valid", suppressConsole); if (!targetNode) return embedError("Target element cannot be determined", suppressConsole); if (page && = page), pdfOpenFragment = function(pdfParams) { let prop, string = ""; if (pdfParams) { for (prop in pdfParams) (prop) && (string += encodeURIComponent(prop) + "=" + encodeURIComponent(pdfParams[prop]) + "&"); string && (string = (string = "#" + string).slice(0, - 1)) } return string }(pdfOpenParams), forcePDFJS && PDFJS_URL) return generatePDFJSMarkup(targetNode, url, pdfOpenFragment, PDFJS_URL, id, title, omitInlineStyles); if (supportsPDFs || assumptionMode && !isMobileDevice) { return function(embedType, targetNode, targetSelector, url, pdfOpenFragment, width, height, id, title, omitInlineStyles) { emptyNodeContents(targetNode); let embed = document.createElement(embedType); if = url + pdfOpenFragment, embed.className = "pdfobject", embed.type = "application/pdf", embed.title = title, id && = id), "iframe" === embedType && = "fullscreen"), !omitInlineStyles) { let style = "embed" === embedType ? "overflow: auto;" : "border: none;"; targetSelector && targetSelector !== document.body ? style += "width: " + width + "; height: " + height + ";" : style += "position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;", embed. = style } return ("pdfobject-container"), (embed), (embedType)[0] }(forceIframe || supportRedirect || isSafariDesktop ? "iframe" : "embed", targetNode, targetSelector, url, pdfOpenFragment, width, height, id, title, omitInlineStyles) } return PDFJS_URL ? generatePDFJSMarkup(targetNode, url, pdfOpenFragment, PDFJS_URL, id, title, omitInlineStyles) : (fallbackLink && (fallbackHTML = "string" == typeof fallbackLink ? fallbackLink : "<p>This browser does not support inline PDFs. Please download the PDF to view it: <a href='[url]'>Download PDF</a></p>", = (/\[url\]/g, url)), embedError("This browser does not support embedded PDFs", suppressConsole)) }; return { embed: function(a, b, c) { return embed(a, b, c) }, pdfobjectversion: "2.2.7", supportsPDFs: supportsPDFs } } //url為文件路徑,id為dom PDFObject.embed(url, id);1.《pdf文件和word文件怎么打開方式?總結(jié)很全面速看!瀏覽器預(yù)覽word、excel、pdf的方式》援引自互聯(lián)網(wǎng),旨在傳遞更多網(wǎng)絡(luò)信息知識(shí),僅代表作者本人觀點(diǎn),與本網(wǎng)站無關(guān),侵刪請(qǐng)聯(lián)系頁腳下方聯(lián)系方式。
2.《pdf文件和word文件怎么打開方式?總結(jié)很全面速看!瀏覽器預(yù)覽word、excel、pdf的方式》僅供讀者參考,本網(wǎng)站未對(duì)該內(nèi)容進(jìn)行證實(shí),對(duì)其原創(chuàng)性、真實(shí)性、完整性、及時(shí)性不作任何保證。
3.文章轉(zhuǎn)載時(shí)請(qǐng)保留本站內(nèi)容來源地址,http://f99ss.com/gl/3034889.html