Loading...

想在網頁上預覽PDF可使用的方案

Temperature: 0 °C

Mark ChangMark Chang
author_tools

使用pdfobject.js

#設定顯示位置
<div id="pdf"></div>

#呼叫pdfobject.min.js
var options = {
pdfOpenParams: {
pagemode: "thumbs",
navpanes: 0,
toolbar: 0,
statusbar: 0,
view: "FitV"
}
};
var myPDF = PDFObject.embed("PDF檔案或位置", "#pdf", options);
var el = document.querySelector("#results");
el.setAttribute("class", (myPDF) ? "success" : "fail");
el.innerHTML = (myPDF) ? "PDFObject successfully added an element to the page!" : "Uh-oh, the embed didn't work.";

Url link
可惜PDFObject雖然好用但對手機系統支援度差。
所以若想在手機上使用可考慮pdf.js

以上紀錄

https://innstory.com/story-想在網頁上預覽PDF可使用的方案-2296
PHP

Prev
 ubuntu_1804__apache_目錄啟用並開啟htaccess_覆寫

Next
JavaScript_搜尋字串並取代 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

使用手機將網址分享到 Line時,如何強制使用預設(外部)瀏覽器開啟?

使用手機將網址分享到 Lin...

如標題,當厭惡了每次在line上面分享demo網址給客戶時點選網址就會使用line的瀏覽器開啟。 還...

點選檔案下載卻直接執行開啟

點選檔案下載卻直接執行開啟

遇到一個情況。 使用者開啟瀏覽器點選某個連結檔案時,不會執行下載而是直接開啟檔案。 原本如果只是圖片...

使用 Closure Compiler 幫 javascript 瘦身

使用 Closure Com...

JavaScript(縮寫為JS)是一種進階的、直譯的程式語言,且作為客戶端手稿語言在使用者的瀏覽器...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format