Skip to content

Controlling window properties (fullscreen, toolbar etc.) #37

Closed
@codesignist

Description

@codesignist

Can we control all of the window parameters? I think this will be useful.
Actually I only need fullscreen property but controlling the other properties could be good.

https://github.com/gregnb/react-to-print/blob/f03aa02caf9a871b9cbf90e9a3c5d1a09fa4f144/src/index.js#L59

I think we could make an object property (windowParams) and override it.

class Example extends React.Component {
  render() {
    return (
      <div>
        <ReactToPrint
          windowParams={{
            fullscreen: 'yes',
          }}
          trigger={() => <a href="#">Print this out!</a>}
          content={() => this.componentRef}
        />
        <ComponentToPrint ref={el => (this.componentRef = el)} />
      </div>
    );
  }
}

And we could convert this object to string.
index.js

const windowParameters = {
  status: 'no',
  toolbar: 'no',
  scrollbar: 'yes',
  ...windowParams
}
//Need a good stringify algorithm or npm project
let printWindow = window.open("", "Print", windowParameters.stringifyProperly(), "false");

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions