npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

customannotation

v1.0.9

Published

standard UI Component for PDF annotation

Downloads

62

Readme

Custom Annotation

PDFJS annotation along with Teserract to capture the data from PDF using angular -6.

Extended for PDF annotate JS library.

Installation

Use the package manager npm to install custom annotation.

npm install customannotation

Configuration

Method 1 :

in angular.json add the below snippet for dependent JS files

  .......

  "assets": [
              "src/favicon.ico",
              "src/assets",
              {
                "glob": "**/*",
                "input": "./node_modules/customannotation/assets/JS",
                "output": "/assets/JS"
              }
            ]

  .......

                                (or)

Method 2 :

copy JS folder from ..node_modules/customannotation/assets and paste 
it into your project mainroot/assets/JS to load dependent JS files 

Usage

in app.module.ts file add the below snippet to import the annotation module

import { AppComponent } from './app.component';
import { CustomannotationModule} from 'customannotation';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    CustomannotationModule,
    FormsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})

export class AppModule { }

in app.component.html file add the below code

 <lk-annotation [(PDFannotations)]="PDFAnnotations" [config]="PDFConfig"
 (pageChanged)="onPageChange($event)" (highlightAnnotationEvent)="annotationHighlight($event)"
  documentId="{{filePath}}" (isPdfLoaded)="endOfPdfloading($event)"></lk-annotation>

in app.component.ts file add the below lines

import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { CustomannotationComponent, PDFconfig } from 'customannotation';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
  encapsulation:ViewEncapsulation.None
})
export class AppComponent implements OnInit {
  title = 'pdftest';
  PDF_info: any = { "currentPage": "1", "totalPages": "" };
  PDFConfig: PDFconfig = { "loadallpages": false, 
                           "history_enabled": false, "rotate": "0", "zoomLevel": 1, 
                           "totalpages": 1, 
                           "useteseract": false,"viewerId":"test-viewer" };
 
  PDFAnnotations: any = [];
  filePath: any = "";

  @ViewChild(CustomannotationComponent)
  private lkannotationcomponent: CustomannotationComponent;
  default_zoom: any;

  ngOnInit() {
    // pass base64 (or) file URL path
    this.filePath = "https://www.hq.nasa.gov/alsj/a17/A17_FlightPlan.pdf"; 
    this.PDFAnnotations = [{
          "x": 167,
          "width": 1989,
          "y": 498,
          "height": 83,
          "page": 1,
          "uuid": "cd21f-ce18-8ad-07d9-c0c6ed8",
          "class": "Annotation",
          "type": "area",
        }];
  }

  annotationHighlight(event) {
    console.log(event);
  }
  endOfPdfloading(event) {
    console.log(event);
  }
  onPageChange(event) {
      this.PDF_info.currentPage = event;
      this.PDF_info.totalPages = this.PDFConfig.totalpages;
  }
 /* set zoom function*/
  setZoom(zoomtype) {
    if (this.default_zoom == undefined) {
      this.default_zoom = JSON.parse(JSON.stringify(this.PDFConfig.zoomLevel));
    }
    switch (zoomtype) {
      case 'in': {
        this.PDFConfig.zoomLevel = this.PDFConfig.zoomLevel - 0.2;
        break;
      }
      case 'out': {
        this.PDFConfig.zoomLevel = this.PDFConfig.zoomLevel + 0.2;
        break;
      }
      case 'reset': {
        this.PDFConfig.zoomLevel = this.default_zoom;  
        break;
      }
    }
 }
 /* to hilight the annotation*/
 hilightAnnotation(uuid){
    this.lkannotationcomponent.highlightAnnotationEvent(uuid);
  }
 /* to edit the annotation*/
 editAnnotation(uuid){
    this.lkannotationcomponent.editAnnotationEvent(uuid);
 }
}

Contributing

For major changes, please open an issue first to discuss what you would like to change.

License

MIT