How to display pdf on canvas using angular7 and fabric js


Anjali

I want to display pdf as image on canvas using angular7 and fabric js

I can't find any code to try in angular7

Anjali

Finally I was able to fix this...I have used pdfjsLib and I have imported in my ts file (import * from 'pdfjs-dist/build/pdf' as pdfjsLib ;)

 public src="/assets/myPhotos.pdf";
 showPdf(){
pdfjsLib.getDocument(this.src).then(doc =>{

 // console.log("this file has "+ doc._pdfInfo.numPages+ "pages");
  doc.getPage(1).then(page => {
    var myCanvas =  <HTMLCanvasElement>document.getElementById("my_canvas");
    var context = myCanvas.getContext("2d");
    var scale = 1.5;
    var viewport = page.getViewport(scale);
    myCanvas.width = viewport.width;
    myCanvas.height = viewport.height;

    page.render({
      canvasContext : context,
      viewport : viewport
    })
  })
});

}

Related


How to set canvas border circle using fabric js in angular

jk123 How can I make my canvas circular so my objects/logos don't go beyond the circular shirt color, please see the attached picture that the canvas is square by default, what I want is the circular behavior of the canvas. I have tried using css but the behav

How to display value in webpage using angular7

Kasik Selwakumar I get the value from the API and it can be displayed in the console log. But I can't view it on the webpage. I don't know what I'm doing wrong there. Can anyone update how I implement and display the value in html? home.component.ts import { C

How to display value in webpage using angular7

Kasik Selwakumar I get the value from the API and it can be displayed in the console log. But I can't view it on the webpage. I don't know what I'm doing wrong there. Can anyone update how I implement and display the value in html? home.component.ts import { C

How to save image using canvas in fabric.js

Bhupendra Emerald I'm creating an app for t-shirt customization, in which I have put a canvas on an image using CSS, but the problem is saving the image as a canvas. toDataURLJust gives a part of the canvas area, but I want the whole image. There are other sol

How to remove image from Fabric.js canvas using button

explain I am new to canvas and Fabric.js. I followed some tutorials and now I can add the image to the canvas. But don't know how to remove it. by clicking a button HTML <div id="container"> <input type="file" id="imageLoader" name="imageLoader" /> <inpu

How to draw a line on canvas using fabric.js

username I am using fabric.js to draw a line on a canvas. Here is my code, but there is no output: $("#Line").click(function() { // alert("Line"); canvas.add(new fabric.Line([50, 100, 200, 200], { left: 170, top: 150, fill: 'red

How to remove image from Fabric.js canvas using button

explain I am new to canvas and Fabric.js. I followed some tutorials and now I can add the image to the canvas. But don't know how to remove it. by clicking a button HTML <div id="container"> <input type="file" id="imageLoader" name="imageLoader" /> <inpu

How to save image using canvas in fabric.js

Bhupendra Emerald I'm creating an app for t-shirt customization, in which I have put a canvas on an image using CSS, but the problem is saving the image as a canvas. toDataURLJust gives a part of the canvas area, but I want the whole image. There are other sol

How to save image using canvas in fabric.js

Bhupendra Emerald I'm creating an app for t-shirt customization, in which I have put a canvas on an image using CSS, but the problem is saving the image as a canvas. toDataURLJust gives a part of the canvas area, but I want the whole image. There are other sol

How to remove image from Fabric.js canvas using button

explain I am new to canvas and Fabric.js. I followed some tutorials and now I can add the image to the canvas. But don't know how to remove it. by clicking a button HTML <div id="container"> <input type="file" id="imageLoader" name="imageLoader" /> <inpu

Fullscreen canvas mode using fabric.js

Pavel Arapov I try to use fullscreen mode (HTML5 fullscreen) with Fabric.js' canvas object. var canvas = fabricCanvas.getSelectionElement(); if(canvas.requestFullScreen) { canvas.requestFullScreen(); } else if(canvas.webkitRequestFullScreen) { canvas.w

How to implement canvas panning with Fabric.js

Dmitrii Pisarenko: I have a Fabric.js canvas and I want to implement the full canvas panning that packages usually do with "manual" tools. This is when you press one of the mouse buttons, then move on the canvas while holding down the mouse button, and the vis

How to implement canvas panning with Fabric.js

Dmitrii Pisarenko: I have a Fabric.js canvas and I want to implement the full canvas panning that packages usually do with "manual" tools. This is when you press one of the mouse buttons, then move on the canvas while holding down the mouse button, and the vis

How to implement canvas panning with Fabric.js

entities I have a Fabric.js canvas and I want to achieve full canvas panning which is usually performed by a "manual" tool. This is when you press one of the mouse buttons, then move on the canvas while holding down the mouse button, and the visible part of th

How to implement canvas panning with Fabric.js

Dmitrii Pisarenko: I have a Fabric.js canvas and I want to implement the full canvas panning that packages usually do with "manual" tools. This is when you press one of the mouse buttons, then move on the canvas while holding down the mouse button, and the vis

Display image only when selected on canvas Fabric JS

Chris I'm trying to add an image to a canvas using JS fabric, but the image only appears when I click or select the area around it (i.e. the group object). The image should show up as soon as the page loads. Here is a snippet of the source code. Any help would

Display image only when selected on canvas Fabric JS

Chris I'm trying to add an image to a canvas using JS fabric, but the image only appears when I click or select the area around it (i.e. the group object). The image should show up as soon as the page loads. Here is a snippet of the source code. Any help would

Display image only when selected on canvas Fabric JS

Chris I'm trying to add an image to a canvas using JS fabric, but the image only appears when I click or select the area around it (i.e. the group object). The image should show up as soon as the page loads. Here is a snippet of the source code. Any help would