{"id":4417,"url":"https://github.com/christopherdro/react-native-html-to-pdf","last_synced_at":"2025-08-04T01:32:22.900Z","repository":{"id":2498893,"uuid":"41897409","full_name":"christopherdro/react-native-html-to-pdf","owner":"christopherdro","description":"Convert html strings to PDF documents using React Native","archived":false,"fork":false,"pushed_at":"2024-06-14T11:28:01.000Z","size":273,"stargazers_count":436,"open_issues_count":25,"forks_count":270,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-07T15:06:30.081Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/christopherdro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-04T04:18:04.000Z","updated_at":"2024-11-07T10:21:04.000Z","dependencies_parsed_at":"2024-01-08T01:03:04.361Z","dependency_job_id":"e75864b4-7ecb-4be5-8b6d-77f05350b5da","html_url":"https://github.com/christopherdro/react-native-html-to-pdf","commit_stats":{"total_commits":82,"total_committers":39,"mean_commits":"2.1025641025641026","dds":0.6585365853658536,"last_synced_commit":"0d77c62b70b9ef599bc7973f0073419769cec78d"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherdro%2Freact-native-html-to-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherdro%2Freact-native-html-to-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherdro%2Freact-native-html-to-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopherdro%2Freact-native-html-to-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christopherdro","download_url":"https://codeload.github.com/christopherdro/react-native-html-to-pdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228582487,"owners_count":17940587,"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":[],"created_at":"2024-01-05T20:17:11.274Z","updated_at":"2024-12-07T08:30:37.099Z","avatar_url":"https://github.com/christopherdro.png","language":"Java","funding_links":[],"categories":["Components","\u003ca name=\"Image-\u0026-Audio-\u0026-Video-\u0026-Docs:-Native-Modules\"\u003eImage, Audio, Video \u0026 Docs: Native Modules\u003c/a\u003e"],"sub_categories":["Text \u0026 Rich Content"],"readme":"# react-native-html-to-pdf\n\nConvert html strings to PDF documents using React Native\n\n## Installation\n\n1. Run `npm install react-native-html-to-pdf --save`\n\n### Option 1: Automatic\n\n2. Run `react-native link`\n\n### Option 2: Manual\n\n#### iOS\n\n2. Open your project in XCode, right click on [Libraries](http://url.brentvatne.ca/jQp8) and select [Add Files to \"Your Project Name](http://url.brentvatne.ca/1gqUD).\n3. Add `libRNHTMLtoPDF.a` to `Build Phases -\u003e Link Binary With Libraries`\n   [(Screenshot)](http://url.brentvatne.ca/17Xfe).\n\n#### Android\n- Edit `android/settings.gradle` to included\n\n```java\ninclude ':react-native-html-to-pdf'\nproject(':react-native-html-to-pdf').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-html-to-pdf/android')\n```\n\n- Edit `android/app/build.gradle` file to include\n\n```java\ndependencies {\n  ....\n  compile project(':react-native-html-to-pdf')\n\n}\n```\n\n- Edit `MainApplication.java` to include\n\n```java\n// import the package\nimport com.christopherdro.htmltopdf.RNHTMLtoPDFPackage;\n\n// include package\nnew MainReactPackage(),\nnew RNHTMLtoPDFPackage()\n```\n\n- Add the following `WRITE_EXTERNAL_STORAGE` permission to `AndroidManifest.xml`\n\n```xml\n\u003cuses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/\u003e\n```\nAlso starting from Android M, users need to be prompted for permission dynamically. Follow [this](https://facebook.github.io/react-native/docs/permissionsandroid) link for more details on how to do that.\n\n\n## Usage\n```javascript\n\nimport React, { Component } from 'react';\n\nimport {\n  Text,\n  TouchableHighlight,\n  View,\n} from 'react-native';\n\nimport RNHTMLtoPDF from 'react-native-html-to-pdf';\n\nexport default class Example extends Component {\n  async createPDF() {\n    let options = {\n      html: '\u003ch1\u003ePDF TEST\u003c/h1\u003e',\n      fileName: 'test',\n      directory: 'Documents',\n    };\n\n    let file = await RNHTMLtoPDF.convert(options)\n    // console.log(file.filePath);\n    alert(file.filePath);\n  }\n\n  render() {\n    return(\n      \u003cView\u003e\n        \u003cTouchableHighlight onPress={this.createPDF}\u003e\n          \u003cText\u003eCreate PDF\u003c/Text\u003e\n        \u003c/TouchableHighlight\u003e\n      \u003c/View\u003e\n    )\n  }\n}\n```\n\n## Options\n\n| Param | Type | Default | Note |\n|---|---|---|---|\n| `html` | `string` |  | HTML string to be converted\n| `fileName` | `string` | Random  | Custom Filename excluding .pdf extension\n| `base64` | `boolean` | false  | return base64 string of pdf file (not recommended)\n| `directory` | `string` |default cache directory| Directory where the file will be created (`Documents` folder in example above). Please note, on iOS `Documents` is the only custom value that is accepted.\n| `height` | number | 792  | Set document height (points)\n| `width` | number | 612  | Set document width (points)\n\n\n#### iOS Only\n\n| Param | Type | Default | Note |\n|---|---|---|---|\n| `paddingLeft` | number | 10  | Outer left padding (points)\n| `paddingRight` | number | 10  | Outer right padding (points)\n| `paddingTop` | number | 10  | Outer top padding (points)\n| `paddingBottom` | number | 10  | Outer bottom padding (points)\n| `padding` | number | 10 | Outer padding for any side (points), overrides any padding listed before\n| `bgColor` | string | #F6F5F0 | Background color in Hexadecimal\n\n\n#### Android Only\n\n| Param | Type | Default | Note |\n|---|---|---|---|\n| `fonts` | Array | | Allow custom fonts `['/fonts/TimesNewRoman.ttf', '/fonts/Verdana.ttf']`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherdro%2Freact-native-html-to-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristopherdro%2Freact-native-html-to-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopherdro%2Freact-native-html-to-pdf/lists"}