I have a problem with read or view pdf in app with ionic vue. I have already try to use library of all vue pdf viewer, but until now no one is supported with vue 3 and ionic.
At least i have tried using in app browser ionic native, but its also not working, only showing blank page.
My code:
<template>
<ion-page>
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button
:default-href="pageDefaultBackLink"
></ion-back-button>
</ion-buttons>
<ion-title>{{ document.judul }}</ion-title>
<ion-buttons slot="end">
<slot name="actions-end"></slot>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content >
<in-app-browser/>
</ion-content>
</ion-page>
</template>
<script>
import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonBackButton} from '@ionic/vue';
import axios from 'axios'
import { onMounted, ref } from 'vue'
import { format } from 'date-fns'
import { useRoute } from 'vue-router'
import { InAppBrowser } from '@ionic-native/in-app-browser';
export default {
name: 'Tab1',
components: {IonHeader, IonToolbar, IonTitle, IonContent, IonPage, IonBackButton, InAppBrowser},
setup() {
let document = ref([])
const options = [{
location: 'no',
zoom: 'no',
hideurlbar: 'yes',
toolbarposition: 'bottom'
}]
InAppBrowser.create('http://www.africau.edu/images/default/sample.pdf', '_self', options)
const route = useRoute()
onMounted(() => {
getDocument()
})
function getDocument(){
axios.get(`document/${route.params.id}`)
.then(response => {
document.value = response.data
}).catch(error => {
console.log(error.response.data)
})
}
return {
document,
getDocument,
format,
}
}
}
</script>
Maybe there is have another better library choice for view pdf in app with ionic vue. Thanks before.