Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added initial implementation of nuxt-pdf #1

Merged
merged 8 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renamed exported function
  • Loading branch information
zoey-kaiser committed Jan 25, 2023
commit 4b4fa23339e29febabcdf71bd60abc5ca02a1c20
4 changes: 2 additions & 2 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import { useNuxtApp } from '#app'
import { ref } from 'vue'
import { Html2PdfOptions } from '../src/runtime/plugin.client'

const { $html2pdf } = useNuxtApp()
const { $exportToPDF } = useNuxtApp()

const page = ref<HTMLElement | null>(null)
const pdfSection = ref<HTMLElement | null>(null)

const print = async (element: HTMLElement, options: Html2PdfOptions) => {
await $html2pdf(element, options)
await $exportToPDF(element, options)
}
</script>
4 changes: 2 additions & 2 deletions src/runtime/plugin.client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-expect-error html2pdf doesn't have type definitions, adding them here for now
import { defineNuxtPlugin } from '#app'
// @ts-expect-error html2pdf doesn't have type definitions, adding them here for now
import html2pdf from 'html2pdf.js'

export interface HTML2CanvasOptions {
Expand Down Expand Up @@ -54,7 +54,7 @@ export interface Html2PdfOptions {
export default defineNuxtPlugin(() => {
return {
provide: {
html2pdf: (element: HTMLElement, options: Html2PdfOptions) => {
exportToPDF: (element: HTMLElement, options: Html2PdfOptions) => {
return html2pdf(element, options)
}
}
Expand Down