arkokoley / pdfvuer

A PDF viewer for Vue using Mozilla's PDF.js that supports both Vue2 and Vue3
https://arkokoley.github.io/pdfvuer
MIT License
918 stars 131 forks source link

example of base64 pdf #136

Open spormeon opened 2 years ago

spormeon commented 2 years ago

would you have any expample of using a base64 coded pdf, I'm getting a value back which is from a "token" which is "billingtaxform", this come in as base64, as we are tokenising the data for PII compliance. I can get a pdf to view using the src, such as this but cant for the life of me get the base64 decoding working?

benryanwilliams commented 2 years ago

You can pass the base64 string into the src parameter as follows:

<template>
  <pdf :src="fullString" :page="1">
    <template v-slot:loading>
      loading content here...
    </template>
  </pdf>
</template>

<script>
import pdf from 'pdfvuer'

export default {
  data() {
    return {
      pdfString: null
    }
  },
  computed: {
    fullString() {
      return "data:application/pdf;base64," + this.pdfString
    }
  },
  components: {
    pdf
  }
}
</script>