You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when downloading the image using desktop it works fine, but when i try on mobile devices or using the desktop responsive, downloading images started a strange behavior, as images on the downloaded canvas moves to the right bottom. this is my code:
const captureScreenshotPlayerRecordVsTeam = async () => {
try {
if (divRefPlayerForm.current) {
// Increase scale for higher quality
const scale = 1;
// Set DPI for higher quality
const dpi = 300;
const canvas = await html2canvas(divRefPlayerForm.current, {
scale: scale,
useCORS: true, // Enable CORS for capturing external images
});
// Convert canvas to a data URL
const dataUrl = canvas.toDataURL('image/png', 1.0); // Use PNG format with high quality
// You can now save or display the screenshot as needed
console.log(dataUrl);
// Create an anchor element for downloading
const downloadLink = document.createElement('a');
downloadLink.href = dataUrl;
downloadLink.download = `${selectedElement?.web_name} form ${ (home && !away) ? " Home " : (away && !home) ? " Away " : '' } GW${startGw}-${endGw}.png`; // Specify the filename
// Trigger the download programmatically
downloadLink.click();
}
} catch (error) {
console.error('Error capturing screenshot:', error);
} finally {
}
};
I searched and found this solution but its not working.
// Adjust viewport for mobile devices
if (screen.width < 1024) {
document.getElementById("viewport")?.setAttribute("content", "width=1200px");
}
The text was updated successfully, but these errors were encountered:
I am facing a similar issue but the in my case image gets shifted to top left and also get cropped automatically, basically mobile device is unable to capture the whole image in the canvas
when downloading the image using desktop it works fine, but when i try on mobile devices or using the desktop responsive, downloading images started a strange behavior, as images on the downloaded canvas moves to the right bottom.
this is my code:
I searched and found this solution but its not working.
The text was updated successfully, but these errors were encountered: