Last active
February 25, 2022 22:46
-
-
Save fronterior/073e2cac4e748337ce882bc0988175c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Only .ai file with PDF compatible. | |
Except IE... | |
*/ | |
const AI_FILE_DIR = './test.ai' | |
const main = async () => { try { | |
const res = await fetch(AI_FILE_DIR) | |
const originBlob = await res.blob() | |
const pdfBlob = originBlob.slice(0, originBlob.size, 'application/pdf') | |
const iframe = Object.assign(document.createElement('iframe'), {src: URL.createObjectURL(pdfBlob)}) | |
document.body.appendChild(iframe) | |
} catch (error) { | |
throw Error(error) | |
}} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment