#React.js printing components (saving as pdf)

24 messages · Page 1 of 1 (latest)

half basalt
#

I have a react page with bunch of stuff including charts from apexcharts etc., and in the page that i want to print, i only want to print a few components from the page.

To achieve that, i have to open up a new window (window.open()), with those components in it, and then print that window right? (window.print())

If that's the case, because react is a spa, the styling doesn't transfer (i've just tried). With createPortal, i can send my components and like i said, styling is not transferred. I followed here;
https://stackoverflow.com/a/64391469

Is there a way to transfer the stylings as well, and i think i need to transfer javascript stuff too?

How is this usually done? Do i need to create a new route straight up and render what i need to render? and the user prints that?

weary canopy
#

styling is just CSS. copy whatever you're loading elsewhere that's needed

#

better to generate the raw html you need, rather than relying on react/js

half basalt
half basalt
#

How is what i'm trying to achieve usually done?

#

I couldn't find any examples

weary canopy
half basalt
#

btw i want to ask something unrelated

#

there are packages such as html2canvas. Wherever you go, people reference this package which is okay. But i go into the github repo of this package and the last commit is like from a year ago, issues are left open and all that. But you look at the weekly downloads and stuff they are lit.

#

I came to the conclusion that the package was not being maintained anymore judging by the commits and issues in the repo.

#

Am i correct for doing so?

#

and whne you compare related packages using npm trends, html2canvas is the best

#

so whats going on is this package maintained still or not?

#

@weary canopy

weary canopy
#

no, it doesn't appear to be actively maintained, but they did check in some fixes last year. some packages are "stable enough" and can last a long time without updates.

half basalt
#

right?

#

and also

#

in its npmjs decsription, it states that the script is higly experimental. therefor its probably dead since not even any experimenting is going on 😄

#

aight

#

but my ways to conclude if a code is maintained or not is correct right?