-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Mobile Chrome prints entire page instead of target content #526
Comments
Hello. Could you be more specific please? What operating system and what browser? Also, if you could share your code that would be very helpful. |
I've same issue here, i'm using android & chrome for the browser |
@xihelmy any chance you could share some code please? A codesandbox replicating the issue would be ideal |
Layout print: export const NPPKBDocument = forwardRef((props, ref) => {
return (
<div ref={ref}>
// some view
</div>
);
}); React to print button : export const ModalPrint = () => {
const componentRef = useRef(null);
const reactToPrintContent = useCallback(() => {
return componentRef.current;
}, [componentRef.current]);
const reactToPrintTrigger = useCallback(() => {
return (
<button className="base-btn-primary fs-14 mr-3 float-right">
Print
</button>
);
}, []);
const pageStyle = `
@page {
margin-top: 12mm;
size: 120mm 140mm;
}
`;
return (
<div className="modal">
<ReactToPrint
content={reactToPrintContent}
pageStyle={pageStyle}
documentTitle="Dokumen"
removeAfterPrint
trigger={reactToPrintTrigger}
/>
</div>
);
}; It's look good on my PC, but when i try to print on mobile, it print entire page |
Same issue for me. Looks ok on Windows laptop + Chrome but prints entire page on iOS 15.6.1 + Chrome. Works as expected on iOS 15.6.1 + Safari. |
@headstar thanks for the datapoint! I'm fearing that this is an upstream issue with Chrome and not an issue with |
I've also verified that the official demo CodeSandbox has the same issue when I try to print it on my Android Chrome |
Sorry for the late response, I've solved this issue, by set |
Oh, that's really interesting @xihelmy! It would mean then that mobile Chrome does not block when |
Note: this is also being tracked in #187 |
I'm trying to print PDF on mobile, It print entire page not only my specific component!!
The text was updated successfully, but these errors were encountered: