Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
pdfjs-dist-viewer-angular
Advanced tools
Readme
This viewer is a simple pdf viewer based on pdfjs-dist@3.7.107 by Mozilla. This viewer is a non-agnostic web component, which means you can use it in any web application once the script (pdfjs-viewer.js) is imported. It is a refactored version of this example https://mozilla.github.io/pdf.js/examples with annotations, which makes links clickable.
Install the viewer:
npm install --save pdfjs-dist-viewer-angular
In angular.json
"scripts": [
"node_modules/pdfjs-dist-viewer-angular/pdfjs-viewer.js"
],
...
The pdfjs-viewer.js file has a size of 477kB.
... or lazy loaded (https://angular-extensions.github.io/elements/#/home)
In the module where you import the component using the pdfjs-viewer element, you should define the schema.
...
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
@NgModule({
declarations: [..],
imports: [..],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
In the Angular HTML template
<pdfjs-viewer [base64]="base64"></pdfjs-viewer>
As native HTML
<html lang="en">
<head>
<script src="pdfjs-viewer.js"></script>
</head>
<body>
<pdfjs-viewer url="https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf"></pdfjs-viewer>
</body>
</html>
Property | Type |
---|---|
[url] | *string |
[url] | {data: atob(JVBERi0xLjQKJeLjz9MK...)} |
Pass pdf location
[url]="'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf'"
Or as a BLOB:
[url]="'blob:http://localhost:4200/eb7533b8-d1bf-4bd7-bb6c-e351df579d51'"
base64, just the Base64 value ✓:
base64 = "JVBERi0xLjQKJeLjz9MKMyAwIG9iagpbL0NhbFJH..
Do NOT use a base64 data URI string ✗:
base64 = "data:application/pdf;base64<JVBERi0xLjQKJeLjz>
Property | Type | Required |
---|---|---|
[page] | number | Optional |
Page number
[page]="1"
If not defined, the viewer shows all pages by default
Property | Type | Required |
---|---|---|
(rendered) | callback | Optional |
Get event when a page is rendered.
(rendered)="rendered($event)"
Property | Type | Required |
---|---|---|
(error) | callback | Optional |
Error handling callback
(error)="onError($event)"
FAQs
pdfjs-dist non-agnostic language viewer
The npm package pdfjs-dist-viewer-angular receives a total of 9 weekly downloads. As such, pdfjs-dist-viewer-angular popularity was classified as not popular.
We found that pdfjs-dist-viewer-angular demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.