
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
ng2-pdfjs-viewer
Advanced tools
To use this library.
git clone -b gh-pages https://github.com/mozilla/pdf.js.git pdfjs-gh-pages
Or simply download 2. To install this library, run:
$ npm install ng2-pdfjs-viewer --save
and then from your Angular AppModule
:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import PdfJsViewerComponent component
import { PdfJsViewerComponent } from 'ng2-pdfjs-viewer';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Add to imports
PdfJsViewerComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Once your PdfJsViewerComponent is imported you can use it in your Angular application like this:
<!-- You can now use your library component in app.component.html -->
<h1>
{{title}}
</h1>
<ng2-pdfjs-viewer pdfSrc="your pdf file path"></ng2-pdfjs-viewer>
Here is a use case to download and open the pdf as byte array and open in new tab/window: Please note, pdfSrc can be a Blob or Uint8Array as well For [externalWindow]="true" to work, pop-ups needs to be enabled at browser level
<!-- your.component.html -->
<button (click)="openPdf();"></button>
<ng2-pdfjs-viewer #pdfViewer style="width: 800px; height: 400px"
[externalWindow]="true"
[openFile]="false"
[viewBookmark]="false"
[download]="false"></ng2-pdfjs-viewer>
<!-- your.component.ts-->
export class RateCardComponent implements OnInit {
@ViewChild('pdfViewer') pdfViewer
...
private downloadFile(url: string): any {
return this.http.get(url, { responseType: ResponseContentType.Blob }).map(
(res) => {
return new Blob([res.blob()], { type: "application/pdf" });
});
}
public openPdf() {
let url = "url to fetch pdf as byte array";
this.downloadFile(url).subscribe(
(res) => {
this.pdfViewer.pdfSrc = res; // pdfSrc can be Blob or Uint8Array
}
);
}
MIT © Code1
FAQs
<img src="h
The npm package ng2-pdfjs-viewer receives a total of 23,276 weekly downloads. As such, ng2-pdfjs-viewer popularity was classified as popular.
We found that ng2-pdfjs-viewer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.