Skip to content

Commit

Permalink
Open PDF in new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertBroersma committed Dec 19, 2023
1 parent 653bfd8 commit 107bbb1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
GridComponent,
} from 'echarts/components'
import VChart, { THEME_KEY } from 'vue-echarts'
import { endsWith } from 'lodash'
type ItemType = typeof itemShape
type CatalogType = typeof catalogShape
Expand Down Expand Up @@ -346,6 +347,24 @@ async function downloadNotebook() {
URL.revokeObjectURL(url)
}
let isLoadingPdf = ref(false)
async function downloadPdf() {
isLoadingPdf.value = true
let file = await $fetch(`${pdfLink.value}`, {
headers,
})
let url = URL.createObjectURL(file)
// let a = document.createElement('a')
// a.href = url
// a.download = 'report.pdf'
// a.click()
// URL.revokeObjectURL(url)
let w = window.open(url)
isLoadingPdf.value = false
}
let pdfLink = ref('')
</script>

Expand Down Expand Up @@ -434,7 +453,10 @@ let pdfLink = ref('')
<v-btn @click="downloadNotebook" prepend-icon="mdi-language-python"
>Download Notebook</v-btn
>
<v-btn :href="pdfLink" target="_blank" prepend-icon="mdi-file-pdf-box"
<v-btn
@click="downloadPdf"
:loading="isLoadingPdf"
prepend-icon="mdi-file-pdf-box"
>Download PDF</v-btn
>
</div>
Expand Down

0 comments on commit 107bbb1

Please sign in to comment.