Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,37 @@ These options are limited to the available settings for [HTMLCanvasElement.toDat

The Worker object returned by `html2pdf()` has a built-in progress-tracking mechanism. It will be updated to allow a progress callback that will be called with each update, however it is currently a work-in-progress.

## Multiple pages

The `html2pdf` would failed with too many pages, because of the canvas limitations.
For more information check this issue [#19](https://github.com/eKoopmans/html2pdf.js/issues/19)

You can split your page into smaller chunks and individually adding them into the PDF.

```js
const pages = Array.from(document.querySelectorAll('.page'));
const opt = {};

let worker = html2pdf()
.from(pages[0])
.set(opt)
.toPdf();

pages.forEach(function(page, idx) {
worker = worker
.get('pdf')
.then(pdf => {
if (!idx) return;
pdf.addPage();
})
.from(page)
.toContainer()
.toCanvas()
.toPdf(idx + 1);
});
worker = worker.save();
```

## Dependencies

html2pdf.js depends on the external packages [html2canvas](https://github.com/niklasvh/html2canvas), [jsPDF](https://github.com/MrRio/jsPDF), and [es6-promise](https://github.com/stefanpenner/es6-promise). These dependencies are automatically loaded when using NPM or the bundled package.
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/hyperlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ Worker.prototype.toContainer = function toContainer() {
});
};

Worker.prototype.toPdf = function toPdf() {
Worker.prototype.toPdf = function toPdf(forcePage) {
return orig.toPdf.call(this).then(function toPdf_hyperlink() {
// Add hyperlinks if the option is enabled.
if (this.opt.enableLinks) {
// Attach each anchor tag based on info from toContainer().
linkInfo.forEach(function(l) {
this.prop.pdf.setPage(l.page);
this.prop.pdf.setPage(forcePage || l.page);
this.prop.pdf.link(l.left, l.top, l.clientRect.width, l.clientRect.height,
{ url: l.link.href });
}, this);
Expand Down