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

Return a print function from usePDF #1420

Conversation

DanMHammer
Copy link
Contributor

Adds a print function to usePDF to add a hidden iframe to document, assign the pdf url to the iframe, print it, and then remove it.

Updates Readme with a usage example.

@diegomura
Copy link
Owner

Thanks for this contribution! I have doubts if this should be added to this hook or can be provided as a separate fn. I'll give this some second thoughts but let me know what you think or if there's another way :)

@diegomura
Copy link
Owner

I just found out this: #1388 (comment)

IMO it's a great solution. I'm not a huge fan of bundling all the features inside react-pdf while they can be achieved by third-party libs. This way we can keep this module as small as possible (it's not small already) and at the same time we reduce the amount of code to maintain in this end which it's already a lot. Let me know what you think

@DanMHammer
Copy link
Contributor Author

print-js is not compatible with NextJS (and possibly any other static generation, but I haven't confirmed), and the maintainer has not responded to an open PR from Mar 1 to merge in a fix.

However, it's pretty trivial for users of ReactPDF to do exactly what I did in this function and just pass in the instance.url if you don't feel like it fits into the library. It might be worth putting this example and the print-js version into documentation somewhere though.

@DanMHammer DanMHammer closed this Jul 29, 2021
@daphnesmit
Copy link

Anybody looking here for a fix. I ported library (everything except the Modal functionality, because thats UI IMHO):
(I am planning to rewrite to Typescript)
https://www.npmjs.com/package/prntr

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.

3 participants