Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add jsPDF setProperties to save method and documentProperties to options #635

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

reliacon-dev
Copy link

No description provided.

@reliacon-dev
Copy link
Author

reliacon-dev commented Mar 15, 2023

This is in lieu of the current workaround (which may be useful to the community to document), which requires the implementer to intercept the pdf to directly apply the jsPDF methods themselves:

import * as html2pdf from 'html2pdf.js';
import jsPDF from 'jspdf';
...
const element = document.getElementById('my-element-id');
const worker = html2pdf();
worker.set({
     // options
})
.from(element)
.outputPdf() // generates the PDF prop which can be intercepted
.then(() => {
  // intercept staged PDF to directly apply jsPDF functions
  const pdf: jsPDF = worker.prop.pdf;
  pdf.setProperties({
    title: 'My PDF',
  });
  return worker.save('my-pdf.pdf');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant