{"id":21135862,"url":"https://github.com/hanzhangyu/rc-print","last_synced_at":"2025-07-09T03:33:16.375Z","repository":{"id":50459709,"uuid":"101882252","full_name":"hanzhangyu/rc-print","owner":"hanzhangyu","description":"print easily","archived":false,"fork":false,"pushed_at":"2018-03-03T17:32:19.000Z","size":161,"stargazers_count":24,"open_issues_count":2,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T05:38:27.498Z","etag":null,"topics":["print","react"],"latest_commit_sha":null,"homepage":"https://hanzhangyu.github.io/rc-print","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanzhangyu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-30T13:05:13.000Z","updated_at":"2024-06-12T18:08:02.000Z","dependencies_parsed_at":"2022-08-25T08:40:34.531Z","dependency_job_id":null,"html_url":"https://github.com/hanzhangyu/rc-print","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhangyu%2Frc-print","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhangyu%2Frc-print/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhangyu%2Frc-print/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhangyu%2Frc-print/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanzhangyu","download_url":"https://codeload.github.com/hanzhangyu/rc-print/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225482437,"owners_count":17481212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["print","react"],"created_at":"2024-11-20T06:59:27.328Z","updated_at":"2024-11-20T06:59:27.884Z","avatar_url":"https://github.com/hanzhangyu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# rc-print\n\nCreate a `iframe` or `new window` to print a part of page what you want. Considering the [a-x-/react-easy-print](https://github.com/a-x-/react-easy-print) if you don`t like to use these two methods\n\n[![NPM version](https://img.shields.io/npm/v/rc-print.svg?style=flat)](https://npmjs.org/package/rc-print)\n[![Build Status](https://www.travis-ci.org/hanzhangyu/rc-print.svg?branch=master)](https://www.travis-ci.org/hanzhangyu/rc-print)\n[![Coverage Status](https://coveralls.io/repos/github/hanzhangyu/rc-print/badge.svg?branch=master)](https://coveralls.io/github/hanzhangyu/rc-print?branch=master)\n[![NPM downloads](http://img.shields.io/npm/dm/rc-print.svg?style=flat)](https://npmjs.org/package/rc-print)\n\n[中文请看这里](./README_zh-CN.md)\n\n# 1. Install\n\n```sh\nnpm install --save rc-print\n```\n\n#### How to run the demo:\n1.  https://hanzhangyu.github.io/rc-print\n2. local demo:\n    \n    ```sh\n    git clone git@github.com:hanzhangyu/rc-print.git\n    \n    npm install\n    \n    npm start\n    ```\n    \n    then open [http://127.0.0.1:8080/](http://127.0.0.1:8080/) in your browser.\n    \n#### How to run the test:\n\n```sh\nnpm run test\n```\n\n\n# 2. Usage  \n\nUse media query to hide the part which is no need to print in the `Print` component.\n\u003e css\n```css\n@media print{\n    .printHide{\n        visibility: hidden;\n    }\n}\n```\n\u003e js\n```js\nclass demo extends Component {\n    render() {\n        return (\n            \u003cdiv\u003e\n                \u003cbutton\n                    onClick={() =\u003e {\n                        this.refs.test.onPrint();\n                    }}\n                \u003eprint\n                \u003c/button\u003e\n                \u003cPrint\n                    ref=\"test\" insertHead\n                \u003e\n                    \u003cdiv\u003e\n                        \u003cp\u003eshow\u003c/p\u003e\n                        \u003cp className=\"printHide\"\u003ehide\u003c/p\u003e\n                    \u003c/div\u003e\n                \u003c/Print\u003e\n            \u003c/div\u003e\n        );\n    }\n}\n```\n\n更多用法见 https://hanzhangyu.github.io/rc-print\n# 3. Props\n| 名称          | 默认值                      | 描述                      |\n| -----------   | ----------------------------| --------------------------- |\n| insertHead    | true              |    Insert the head tag             |\n| ignoreHeadJs    | true              |    Ignore the js files when `insertHead` is enabled             |\n| bodyStyle     | false              |   Insert the style tag in the body (unrecommended method to write style)               | \n| otherStyle    | undefined              |  Other styles are inserted into the style tag which will be created in the last of head             |\n| isIframe      | true     |   Use iframe if it`s true, otherwise new window will be used     |\n| iframeStyle   | 'position:absolute;width:0px;height:0px;'   |   The style of iframe  |\n| winStyle      | 'toolbar=no,menubar=no'          |   [The style of new window](https://developer.mozilla.org/en-US/docs/Web/API/Window/open#Window_features)          |\n| title         | undefined                      |  The title of iframe or new window                      |\n| preventDefault| false                      |  Replace the shortcut key of the browser's native print                    |\n| lazyRender    | false                      |  async render, rendering when printing only                     |\n| clearIframeCache    | false                      |  Clean up the DOM cache.if props changes, it will retain and directly use the DOM left in the last print when choose false                      |\n| singletonCache    | true                      |  Works when clearIframeCache is false. Like Singleton pattern, only one cache will be save when there is multiple component which has a true singletonCache props                |\n| onStart    | function(){}                      |  Begin to print                      |\n| onEnd    | function(){}                      |  Render print page finish       |\n# 4. Feature\nPick up the core code to separate with `react`, or find it. Besides, welcome to recommend.\n\n# 5. LICENSE\nMIT@[PaulHan](https://github.com/hanzhangyu).\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhangyu%2Frc-print","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanzhangyu%2Frc-print","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhangyu%2Frc-print/lists"}