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

Printing like the viewport is on mobile but in reality is on desktop #675

Open
nosinformatica opened this issue Dec 14, 2023 · 3 comments
Open

Comments

@nosinformatica
Copy link

nosinformatica commented Dec 14, 2023

i would like to print this component that is inside a modal
image
but when i print it gets out like this
image

this is the function used to print:

<ReactToPrint
    bodyClass="print-agreement"
    content={() => ref.current}
     trigger={() => (
    <Button variant="contained" type="button" style={{ backgroundColor: 'gray', marginLeft: '2%' }} className="">
    <Download width={15} />PDF
        </Button>
    )}
    pageStyle={`@media print {@page {size: 2000x 2000px; margin: 1cm;}`}
 />

the component is inside a modal

<Modal
  isOpen={open}
  toggle={handleClose}
  centered
  size="lg"
  style={{maxWidth: '1100px', width: '100%'}}
  backdropClassName={open ? 'BDModalOpen' : 'BDModalClosed'}
  modalClassName={open ? 'ModalOpen' : 'ModalClosed'}
>
    <Container fluid={true} style={{ padding: '20px' }}>
        <ReactToPrint
            bodyClass="print-agreement"
            content={() => ref.current}
            trigger={() => (
              <Button variant="contained" type="button" style={{ backgroundColor: 'gray', marginLeft: '2%' }} className="">
                <Download width={15} />PDF
              </Button>
            )}
            pageStyle={`@media print {@page {size: 2000x 2000px; margin: 1cm;}`}
          />
          <div ref={ref} ><CsvGraphs data={jsonData} /></div>
    </Container>
</Modal>
@MatthewHerbst
Copy link
Owner

Hello. Have you checked the styles that your component framework is using? Usually what's happening in cases like this is your framework is using smaller viewport styles when printing.

What component framework are you using?

@nosinformatica
Copy link
Author

Hello. Have you checked the styles that your component framework is using? Usually what's happening in cases like this is your framework is using smaller viewport styles when printing.

What component framework are you using?

Hello, thanks, i'm using reactsrap for the row and col and highcharts for the charts, i'm trying to do a codesandbox reproducing the issue and i will post the link to it as soon as i finish it

@nosinformatica
Copy link
Author

nosinformatica commented Dec 15, 2023

@MatthewHerbst i just finished the sandbox reproducing the error, try to print and you will see that the cols are in mobile mode:
https://codesandbox.io/p/sandbox/wrong-viewport-react-to-print-sandbox-zs4fww?file=%2Fsrc%2FApp.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants