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

iOS: Components seem to be cut or cropped on smaller screen sizes #43

Open
Bodacious opened this issue Feb 13, 2021 · 10 comments
Open

iOS: Components seem to be cut or cropped on smaller screen sizes #43

Bodacious opened this issue Feb 13, 2021 · 10 comments

Comments

@Bodacious
Copy link

I've been using this library on a personal project which you can view here:
https://gavinmorrice.com/russian-squat-routine-generator

When you click the button on a larger screen or desktop computer, it downloads the full table content as expected.

But when you click the button on a small screen or mobile device, it seems to crop out a portion of the image. PNG gives the best result, JPEG is worse, and PDFs are coming down as blank.

Any idea what I can do to fix this? Thanks!

@salman-monetate
Copy link
Collaborator

Hi, I don't see any difference between desktop and mobile for the above link. Both are exactly the same with no crop. Apart from compression, PNG and JPEG should be exactly the same as we only pass filetype to html2canvas and there is no difference in the rest of the parameters.

For pdf check the options available for {w, h, x, y, unit, orientation, pdfFormat}

@Bodacious
Copy link
Author

@salman-monetate thanks for getting back to me.

Could you please tell me which device you tested this on, as I’m still getting the same problem with Safari on iOS (iPhone XS / iOS 14.5)

The image below is what I get on my device.

A3C0E203-1E0C-4470-85CC-FBF07BE4D4FB

@salman-monetate
Copy link
Collaborator

I tried it with Chrome/Brave on Android.

@Bodacious Bodacious changed the title Components seem to be cut or cropped on smaller screen sizes iOS: Components seem to be cut or cropped on smaller screen sizes Feb 15, 2021
@Bodacious
Copy link
Author

Thank you. I've updated the issue title to reflect that it seems to be iOS only.

I see the same buggy behaviour in Chrome on iOS too.

Any idea where I can start looking to resolve this?

@salman-monetate
Copy link
Collaborator

This package heavily relies on html2Canvas, which would be the first place to look into it.

@fredericoo
Copy link

I'm facing the same issue! Did you solve it somehow @Bodacious ?

@fredericoo
Copy link

WORKAROUND
I was able to make it work by forcing the browser to scroll to a point previous to the element I'm trying to save as. Apparently this is an optimisation process or glitch with the browser that once you go past it only renders half of the viewport worth of pixels. This makes it work (but forcefully scrolls to the top).

@JackyLeeCS
Copy link

I faced the same issues, and this option worked for me html2CanvasOptions: { scrollY: 0 }.

@jeffceriello
Copy link

Hi, I am having the same issue but even with html2CanvasOptions: { scrollY: 0 } or the scrollY to the position of the component to export I always get a blank image. Only once I managed to get something like 20px in from the bottom of an image but I never managed to get it again. Is there a stable solution to this issue?

@AyoCodess
Copy link

where do you add the htmlcanvas options?

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

No branches or pull requests

6 participants