GithubHelp home page GithubHelp logo

Comments (6)

beliolfa avatar beliolfa commented on May 18, 2024

Heres a reproduction repo.

https://github.com/disitec/vue-pdf-issue-repro

from vue-pdf.

fincardy avatar fincardy commented on May 18, 2024

I've currently got the same issue with just the JSfiddle in the readme (here: https://jsfiddle.net/fossfiddler/5k4ptmqg/145/)

The page will render the page numbers and corresponding input, but the Canvas is blank. If you resize the window it'll load the PDF correctly. I've had similar issues when trying to integrate it into my current project.

After some Googling, it seems there could be an issue with Vue 2 and the <canvas> element, but the solutions I've found to that are not appropriate for my configuration (more info here: https://laracasts.com/discuss/channels/vue/vue-interfering-with-html5-canvas-somehow)

Tested in Chrome 64.0.3282.119 & Firefox 57.0.4 on OSX High Sierra (10.13.3).

from vue-pdf.

FranckFreiburger avatar FranckFreiburger commented on May 18, 2024

Is there any error in the browser's console ?

from vue-pdf.

fincardy avatar fincardy commented on May 18, 2024

Nope, no console errors on first load or the window resize.

It seems that once it's all loaded you can change the display or opacity property on the Canvas element using DevTools and it'll render it correctly too - though I've not been able to get that working programmatically. It seems to be anything that forces the canvas to redraw.

from vue-pdf.

fincardy avatar fincardy commented on May 18, 2024

Managed to get a hacky fix sorted:

<template>
  <div id="app">
    <div :style="{ maxWidth: pdfWidth }">
      <pdf
        src="https://cdn.mozilla.net/pdfjs/tracemonkey.pdf"
        @loaded="updateWidth"
      />
    </div>
  </div>
</template>

<script>
import pdf from 'vue-pdf'
export default {
  name: 'App',
  components: { pdf },
  data() {
     return {
         pdfWidth: '99%'
     }
  },
  methods: {
    updateWidth: function() {
      var that = this;
      setTimeout(function() {
        that.pdfWidth = '100%';
      }, 1000);
    }
  }
}
</script>

Just need to create a wrapper (the PDF component's width is 100%) with a slightly smaller width on it by default, then use a setTimeout called after the document has loaded to change the wrapper size and force a re-render.

It's not ideal (and my Vue knowledge isn't great) but it works :)

from vue-pdf.

FranckFreiburger avatar FranckFreiburger commented on May 18, 2024

@fincardy, please try v3.1.4+ without your wrapper

from vue-pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.