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

does not provide an export named 'DefaultAnnotationLayerFactory' #106

Open
Lysom opened this issue Sep 6, 2021 · 15 comments
Open

does not provide an export named 'DefaultAnnotationLayerFactory' #106

Lysom opened this issue Sep 6, 2021 · 15 comments

Comments

@Lysom
Copy link

Lysom commented Sep 6, 2021

when I use pdfVuer, there is an issue 'SyntaxError: The requested module '/node_modules/_pdfjs-dist@2.5.207@pdfjs-dist/web/pdf_viewer.js?v=0ddebc6b' does not provide an export named 'DefaultAnnotationLayerFactory'

@arkokoley
Copy link
Owner

Which version of pdfvuer are you using?

@t-sinbo
Copy link

t-sinbo commented Nov 26, 2021

latest and vue3

@t-sinbo
Copy link

t-sinbo commented Nov 26, 2021

latest and vue3

sorry, the next

@ddo
Copy link

ddo commented Dec 7, 2021

any update?

@lffv
Copy link

lffv commented Dec 10, 2021

Same here using @next and vue 3.0.5.

any updates?

@t-sinbo
Copy link

t-sinbo commented Dec 14, 2021

The question maybe cased by vite.

@songkeys
Copy link

Any updates? I can't find any pdf viewer library working with vite+vue3...

@phcreery
Copy link

phcreery commented Jan 25, 2022

Same here

@phcreery
Copy link

I found https://github.com/hrynko/vue-pdf-embed that works for my case.

@PetalsOnaWet
Copy link

Any updates?

@adesr
Copy link

adesr commented Apr 17, 2022

hello, any update on this issue?

@zenflow
Copy link

zenflow commented Apr 28, 2022

So this package doesn't work with Vite

This is the upstream issue in pdfjs: mozilla/pdf.js#10317

https://github.com/hrynko/vue-pdf-embed looks like a good alternative that doesn't have this issue, but lacks the zoom/scale feature.

I think the solution vue-pdf-embed uses could be applied here: make pdfjs built-in so that it's not installed & imported as another dependency in projects that use pdfvuer.

@akbarism
Copy link

I'm using nuxt 3, and vue-pdf-embed doesn't work on nuxt 3, is there any alternative?

@zenflow
Copy link

zenflow commented Jan 25, 2023

God damn it @akbarism maybe try reading what's been posted already, before adding noise to the issue.
The answer to your question is already posted.

@LorDeCry
Copy link

LorDeCry commented Mar 16, 2023

Hello guys. I had same issue, and was looking for solution... I ended up using different library, which is still based on the pdf.js but has a little different setup, using composable function. I figured out how to solve the issue. It works, looks a little bit hacky tho...

So I used https://github.com/TaTo30/VuePDF as an alternative, but the trick was in defining following plugin which is loaded only on client, within which pdf.js loaded (in this particular library its within usePDF)

import { VuePDF, usePDF } from "@tato30/vue-pdf";

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.component("VuePDF", VuePDF);

  return {
    provide: {
      usePDF,
    },
  };
});

So it feels weird to provide composable within plugin, but at the end composable is just a function. Here is an example component how to use it - in my library I first open my modal window with loading notice, and the URL of PDF is fetched dynamically, so I had to listen to URL changes.

<template>
  <div class="text-2xl min-h-[80vh] flex items-center justify-center text-center" v-if="pages === 0">
    Loading PDF Document...
  </div>
  <div class="space-y-6" v-else>
    <VuePDF
      :pdf="pdf"
      :page="page"
      :scale="scale"
      v-for="page in pages"
      :key="page"
      class="justify-center"
      :text-layer="true"
    />
  </div>
</template>

<script setup lang="ts">
const props = withDefaults(
  defineProps<{
    url?: string;
    scale?: number;
  }>(),
  {}
);

const { $usePDF } = useNuxtApp();

let pdf = ref();
let pages = ref(0);
let info = ref();

watch(
  () => props.url,
  () => {
    if (!props.url) {
      return;
    }
    const { pdf: _pdf, pages: _pages, info: _info } = $usePDF(props.url, {});
    pdf = _pdf;
    pages = _pages;
    info = _info;
  },
  { immediate: true }
);
</script>

Maybe you could figure out how to setup it with pdfvuer

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