# rntpc_react-native-print
**Repository Path**: openharmony-sig/rntpc_react-native-print
## Basic Information
- **Project Name**: rntpc_react-native-print
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: https://gitee.com/openharmony-sig/rntpc_react-native-print
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-10-14
- **Last Updated**: 2025-05-07
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 🚨 **重要提示 | IMPORTANT**
>
> **⚠️ 此代码仓已归档。新地址请访问 [rntpc_react-native-print](https://gitcode.com/openharmony-sig/rntpc_react-native-print)。| ⚠️ This repository has been archived. For the new address, please visit [rntpc_react-native-print](https://gitcode.com/openharmony-sig/rntpc_react-native-print).**
>
---
>
# react-native-print
Print documents using React Native.
## Installation
Run `npm install react-native-print --save`
## Add it to your project
### Automatic
Run `react-native link`
### Manual
#### iOS
1. 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).
2. Choose the file `node_modules/react-native-print/RNPrint.xcodeproj`
3. Go to `Project Manager` tab and click on your project's name. Select the name of the target and click on `Build Phases`
4. Add `libRNPrint.a` to `Link Binary With Libraries`
[(Screenshot)](http://url.brentvatne.ca/17Xfe).
#### Android
- Edit `android/settings.gradle` to included
```java
include ':react-native-print'
project(':react-native-print').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-print/android')
```
- Edit `android/app/build.gradle` file to include
```java
dependencies {
....
compile project(':react-native-print')
}
```
- Edit `MainApplication.java` to include
```java
// import the package
import com.christopherdro.RNPrint.RNPrintPackage;
// include package
new MainReactPackage(),
new RNPrintPackage(),
```
#### Windows
1. In `windows/myapp.sln` add the `RNPrint` project to your solution:
- Open the solution in Visual Studio 2019
- Right-click Solution icon in Solution Explorer > Add > Existing Project
- Select `node_modules\react-native-print\windows\RNPrint\RNPrint.vcxproj`
2. In `windows/myapp/myapp.vcxproj` ad a reference to `RNPrint` to your main application project. From Visual Studio 2019:
- Right-click main application project > Add > Reference...
- Check `RNPrint` from Solution Projects.
3. In `pch.h` add `#include "winrt/RNPrint.h"`.
4. In `app.cpp` add `PackageProviders().Append(winrt::RNPrint::ReactPackageProvider());` before `InitializeComponent();`.
### Windows print canvas
On Windows, `react-native-print` needs an element in the visual tree to add the printable pages to.
It will look for a XAML `Canvas` named `RNPrintCanvas` and use it.
This needs to be added to the XAML tree of the screens where `react-native-print` is used.
As an example, in `windows/myapp/MainPage.xaml` from the `react-native-windows` app template this can be done by adding a XAML `Grid` with an invisible `Canvas` alongside the `ReactRootView`. Change `windows/myapp/MainPage.xaml` from:
```xaml