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

Nuxt support #52

Open
CavalcanteLeo opened this issue Mar 23, 2023 · 0 comments
Open

Nuxt support #52

CavalcanteLeo opened this issue Mar 23, 2023 · 0 comments

Comments

@CavalcanteLeo
Copy link

CavalcanteLeo commented Mar 23, 2023

I'm trying to use with nuxt 3, but I'm facing this error:

Failed to launch
'localhost:3000/webviewer/./ui/index.html#d=%22https%3A%2F%2Fpdftron.s3.amazonaws.com%2Fdownloads%2Fpl%2Fdemo-annotated.pdf%22&a=1&filepicker=0&pdfnet=0&enableRedaction=0&disableVirtualDisplayMode=0&enableMeasurement=0&pageHistory=1&notesInLeftPanel=0&autoExpandOutlines=0&enableAnnotationNumbering=0&singleServerMode=false&selectAnnotationOnCreation=0&autoFocusNoteOnAnnotationSelection=1&id=1&basePath=%2F&webViewerJSVersion=8.12.0' because the scheme does not have a registered handler.

component PdfViewer.client.vue:

<script lang="ts" setup>
import WebViewer from '@pdftron/webviewer'

const viewer = ref<HTMLDivElement | null>(null)

onMounted(() => {

})

const initPdfViewer = (viewer: HTMLDivElement) => {
 const path = `${window.location.host}/webviewer`

  WebViewer({ path, initialDoc: props.doc }, viewer).then(
    (instance) => {
      const { documentViewer, annotationManager, Annotations } = instance.Core


      documentViewer.addEventListener('documentLoaded', () => {
        const rectangleAnnot = new Annotations.RectangleAnnotation({
          PageNumber: 1,
          // values are in page coordinates with (0, 0) in the top left
          X: 100,
          Y: 150,
          Width: 200,
          Height: 50,
          Author: annotationManager.getCurrentUser(),
        })
        annotationManager.addAnnotation(rectangleAnnot)
        annotationManager.redrawAnnotation(rectangleAnnot)
      })
    }
  )
}

defineExpose({ viewer })

watchEffect(() => {
  if (viewer.value) {
    initPdfViewer(viewer.value)
  }
})

const props = defineProps({
  doc: {
    type: String,
    required: true,
    default: '',
  },
})

</script>

<template>
  <div>
    <div class="h-screen pdf" ref="viewer"></div>
  </div>
</template>

Screenshot 2023-03-23 at 01 31 29

Screenshot 2023-03-23 at 01 32 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant