An utility tool for export an url to pdf, which depend on chrome headless mode.
For client side rendered webpage. You should invoke window.__notifyPageRenderFinished()
to notify the exporter, or just wait for timeout
.
Document
-
Constructor(options: IPDFExportOptions): ICDPClient
contstructor an exporter instance.
-
export({ url: string, cookies?: ICookieItem[] }): Promise
Visit the url with the given cookies.
-
dispose():void
Kill the child chrome process.
How to use.
-
Install chrome/chromium on your system.
-
npm install pdf-export
-
Usage
const fs = ;const PDFExportor = default;const exporter =host: 'localhost'port: 9333chromeBin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'timeout: 5000;{Promiseallexporterexporterexporterexporter};
Other
This library depend on chrome-remote-interface, which not provide typescript type definitions. So I just write a partial definitions of chrome-remote-inteface
library.