xitanggg / open-resume

OpenResume is a powerful open-source resume builder and resume parser. https://open-resume.com/

Home Page:https://open-resume.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Layout changes do not update a PDF when it's downloaded

shaejaz opened this issue · comments

I noticed that when changing the components and layout of the PDF, the render preview would correctly show the updated layout. However, when I would download the PDF the layout changes would not appear(simple text changes do though).

I tried updating the react-pdf package to v3.1.12 since it had the fix for similar issue people were reporting(diegomura/react-pdf#2247), but no luck. I'm only able to get the download working correctly if I reload the page or the dev server.

The new react-pdf version updated the usePDF hook and I did change the code for it. See my forked branch: main...shaejaz:open-resume:update-react-pdf

commented

I'm running into the same issue @shaejaz, did you find any solution to this? Trying to hardcode some margins for a job near the bottom of the page to make the page break a bit cleaner.

where are you adding the padding/margins?
By adding padding at

, I can see the changes in the pdf

@SkylerA No I haven't managed to find the cause for it yet. My guess is the underlying react-pdf might have a bug or is not being used correctly.

Imo, it's a minor inconvenience since the realtime PDF view gets updated just fine. It's the download link that has the issue. So once you've made your changes on the layout, restart the dev server and the download URL would give you the updated layout.

commented

@p0lygun That is where I was trying. I also tried wrapping the individual components in a view with new styles. The changes show up in the preview window, however when you click download link the styles are lost. Restarting the server after the changes didn't seem to help either.

I believe even the default style might be ignored to some degree as I've noticed that if you add a new work experience with the text Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur id tortor eget erat ornare tempus the preview will wrap tempus to the next line, but when you download the pdf you'll actually see it all fit into 1 line. Note this example is most likely style and text dependent (I'm using Roboto, 11pt, standard, Letter)

commented

Did a bit more research and it looks like this might be an issue in react-pdf itself.

diegomura/react-pdf#1076 mentions that it might be padding/margin specific which i was able to confirm by applying style={{ margin: "3rem", color: "red" }} to the component I link in my previous post. Both the margin and color change render in the preview, but only the color change is saved to pdf.

This post further theorizes that it might be related to string units not surviving being passed as props which i was able to recreate by changing margin: "3rem" to margin: 48 and the change was saved to the pdf.

So I'd say if anyone needs to tweak layout for now, try converting your units to pixels and then setting the value as a number instead of a string. Note i also had to restart server and possibly reload page for changes to go through sometimes, didn't dial down the specific sequence