Skip to content

Instantly share code, notes, and snippets.

@fronterior
Last active February 25, 2022 22:46
Show Gist options
  • Save fronterior/073e2cac4e748337ce882bc0988175c0 to your computer and use it in GitHub Desktop.
Save fronterior/073e2cac4e748337ce882bc0988175c0 to your computer and use it in GitHub Desktop.
/**
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