Gathering detailed insights and metrics for pdf-creation-actions-web-component
Gathering detailed insights and metrics for pdf-creation-actions-web-component
Gathering detailed insights and metrics for pdf-creation-actions-web-component
Gathering detailed insights and metrics for pdf-creation-actions-web-component
Print or pdf generation buttons for printing Tignum reports
npm install pdf-creation-actions-web-component
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (92.61%)
HTML (7.39%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3 Stars
190 Commits
2 Watchers
22 Branches
4 Contributors
Updated on Sep 13, 2022
Latest Version
1.20.7
Package Id
pdf-creation-actions-web-component@1.20.7
Unpacked Size
1.24 MB
Size
413.12 kB
File Count
7
NPM Version
7.15.0
Node Version
16.16.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
31
Packages are released on the public npm registry.
Generate and download multi-page PDF from HTML passed as string to the Web Component.
> npm i pdf-creation-actions-web-component
import 'pdf-creation-actions-web-component';
<print-to-pdf html="<div class="pages-wrapper"><div class="page-1"><style>p {color: red}</style}<p>first page to preview and print</p></div></div>" style="{root style as string}"></print-to-pdf>
The web component listens to a 'download-pdf' event to generate the PDF from the HTML and start a download. You can pass on the attributes the name of the file and the quality of the generated pdf as options (1-4).
For example if you fire the event from a button like this:
<button id="print-pdf" onclick="downloadPdf('filename-requested')">Download Pdf</button>
That function should emit a custom event as follows:
function downloadPdf(filename = 'no-file-name-provided') {
const event = new CustomEvent("download-pdf", {
composed: true,
bubbles: true,
detail: {
fileName: filename,
quality: 2, // to define scale, by default is 4
orientation: 'landscape', //by default is 'portrait'
unit: 'cm', // by default is 'in'
format: 'A4', // by default is 'letter'
},
});
document.getElementById('pdfComponent').shadowRoot.dispatchEvent(event);
}
The web component emits 'progress' events with messages indicating the current state of the pdf generation job.
window.addEventListener('progress', function(event) {
console.log(event.detail.message);
})
}
1- Add to the tag the event 'progress':
<print-to-pdf ... @progress="onProgress" />
2- In the function that you declare "onProgress" capture the event message and then use it as you need it:
function onProgress(event) {
const { detail: { message } } = event;
console.log(message);
}
This component has some styles that can be editable, and are defined in index.js in static styles. Example: By default the color and background are configured like:
:host {
color: var(--content-text-color, black);
background: var(--content-background-color, white);
}
The color and background can be modify by change this variables --content-text-color and ==content-background-color in print-to-pdf tag:
<style>
print-to-pdf {
--content-text-color: white;
--content-background-color: #0000ff;
}
</style>
It is also possible to add css classes:
<print-to-pdf class="my-blue-element" html="<p>Test 1</p>" fileName="pdf-generated-1"></print-to-pdf>
<print-to-pdf class="my-red-element" html="<p>Test 2</p>" fileName="pdf-generated-2"></print-to-pdf>
<style>
print-to-pdf.my-blue-element {
--content-text-color: black;
}
print-to-pdf.my-red-element {
--content-text-color: red;
}
}
</style>
> npm run build
> npm run test
> npm run demo:web
and open:
[http://127.0.0.1:8082/index.html](http://127.0.0.1:8082/index.html)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 6/25 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
61 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More