![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
$ npm install pagedjs
import { Previewer } from 'pagedjs';
let paged = new Previewer();
let flow = paged.preview(DOMContent, ["path/to/css/file.css"], document.body).then((flow) => {
console.log("Rendered", flow.total, "pages.");
})
Add the the paged.polyfill.js
script to replace all @page
css and render the html page with the Paged Media styles applied:
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
Try the polyfill with Aurorae.
By default the polyfill will run automatically as soon as the DOM is ready.
However, you can add an async before
function or return a Promise to delay the polyfill starting.
<script>
window.PagedConfig = {
before: () => {
return new Promise(resolve, reject) {
setTimeout(() => { resolve() }, 1000);
}
},
after: (flow) => { console.log("after", flow) },
};
</script>
Otherwise you can disable auto
running the previewer and call window.PagedPolyfill.preview();
whenever you want to start.
<script>
window.PagedConfig = {
auto: false
after: (flow) => { console.log("after", flow) },
};
setTimeout(() => {
window.PagedPolyfill.preview();
}, 1000);
</script>
Chunks up a document into paged media flows and applies print classes.
Examples:
Converts @page
css to classes, and applies counters and content.
Examples:
Command line interface to render out PDFs of HTML files using Puppeteer: https://gitlab.pagedmedia.org/polyfills/pagedjs-cli.
Modules are groups of handlers for that apply the layout and styles of a CSS module, such as Generated Content.
New handlers can be registered from import { registerHandlers } from 'pagedjs'
or by calling Paged.registerHandlers
on an html page.
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
<script>
class MyHandler extends Paged.Handler {
constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
afterPageLayout(pageFragment, page) {
console.log(pageFragment);
}
}
Paged.registerHandlers(MyHandler);
</script>
Handlers have methods that correspond to the hooks for the parsing, layout and rendering of the Chunker and Polisher. Returning an promise or async
function from a method in a handler will complete that task before continuing with the other registered methods for that hook.
// Chunker
beforeParsed(content)
afterParsed(parsed)
beforePageLayout(page)
afterPageLayout(pageElement, page, breakToken)
afterRendered(pages)
// Polisher
beforeTreeParse(text, sheet)
beforeTreeWalk(ast)
afterTreeWalk(ast, sheet)
onUrl(urlNode)
onAtPage(atPageNode)
onRule(ruleNode)
onDeclaration(declarationNode, ruleNode)
onContent(contentNode, declarationNode, ruleNode)
Install dependencies
$ npm install
Run the local dev-server with livereload and autocompile on http://localhost:9090/
$ npm start
Build the dist
output
$ npm run prepare
Testing for Paged.js uses Jest but is split into Tests and Specs.
Unit tests for Chunker and Polisher methods are run in node using JSDOM.
npm run tests
Specs run a html file in Chrome (using puppeteer) to test against CSS specifications.
They can also output a pdf and compare pages (one at a time) in that PDF with samples PDFs (saved as images).
To test the pdf output of specs, you'll need to build the library locally.
npm run build
Then run the jest tests in puppeteer.
npm run specs
To debug the results of a test in a browser you can add NODE_ENV=debug
NODE_ENV=debug npm run specs
To update the stored pdf images you can run
npm run specs -- --updateSnapshot
A pagedmedia/pagedjs
docker image contains all the dependencies needed to run the pagedjs
development server, as well as the pdf comparison tests.
To build the image run
docker build -t pagedmedia/pagedjs .
By default the container will run the development server with npm start
docker run -it -p 9090:9090 pagedmedia/pagedjs
The tests and specs can be run within the container by passing a seccomp
file for Chrome and running npm test
docker run -it --security-opt 'seccomp=seccomp.json' pagedmedia/pagedjs npm test
The core team behind paged.js includes Adam Hyde, Julie Blanc, Fred Chasen & Julien Taquet.
MIT License (MIT), which you can read here
FAQs
Chunks up a document into paged media flows and applies print styles
The npm package pagedjs receives a total of 0 weekly downloads. As such, pagedjs popularity was classified as not popular.
We found that pagedjs demonstrated a not healthy version release cadence and project activity because the last version was released 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.