stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
469 stars 175 forks source link

Is it possible to stamp an image on the PDF layer or Annotation/Drawn layer using any method u have implemented? #2074

Closed bryanwac closed 7 months ago

bryanwac commented 7 months ago

While reading yours and pdfjs/mozilla docs, saw that we can manually create the divs for the layers, and by this, we can maybe create the canvas manually on TS for the images to become a canvas using something like renderer2 and adding it with the edittable = true to resize it. But I was not able to do taht :c can u help me with this or maybe tell me if this is upcomming on next releases? :D

refs: https://github.com/mozilla/pdf.js/blob/master/web/annotation_editor_layer_builder.js

somehow can manage to transform the images to canvas and inser like this:

    // Criação do elemento canvas
    const canvas = this.renderer.createElement('canvas');
    this.renderer.appendChild(this.elRef.nativeElement, canvas);

    // Configuração do contexto 2D
    const ctx = canvas.getContext('2d');

    // Criação do elemento imagem
    const image = this.renderer.createElement('img');
    this.renderer.setAttribute(image, 'src', 'https://i.pinimg.com/originals/7a/50/6c/7a506c3b52e619fdc469ad8e931497c0.png');

    // Quando a imagem for carregada, desenhe-a no contexto 2D do canvas
    image.onload = () => {
      ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
    };

    // Adiciona a imagem ao DOM para iniciar o carregamento
    this.renderer.appendChild(this.elRef.nativeElement, image);
stephanrauh commented 7 months ago

Basically, you have two options:

Extending the annotation_editor_layer_builder sounds attractive in the long term, but in the short term, that's too much work for me. It's always difficult to guess the direction the base library evolves. If I guess wrong, I'm in a hell of merge conflicts.

bryanwac commented 7 months ago

image

And Can I have this resizers by addint the canva by myself? Or do I need to add all the classes it normaly have to my built-in canva

stephanrauh commented 7 months ago

Talking about new releases: at the moment, I'm trying to understand what the upcoming EU Cyber Resilience Act means for this project. More likely than not, it only means 20% more work for me. However, there's a small danger that ngx-extended-pdf-viewer falls into the same regulation as the Mozilla browser, and that'd be the end of the project.

Until I've read and understood the document (189 pages!), I'll stop implementing new features.

stephanrauh commented 7 months ago

I'm afraid I can answer the question about resizers. The resizers themselves are simple CSS (or so I believe), but I haven't looked at the JavaScript implementation yet.

stephanrauh commented 7 months ago

I'm not sure - are there still questions open?