This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo Print
A library that provides printing functionality for Android and iOS (AirPrint).
expo-print provides an API for Android and iOS (AirPrint) printing functionality.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
API
import * as Print from 'expo-print';
No API data file found, sorry!
Local images
On iOS, printing from HTML source doesn't support local asset URLs (due to WKWebView limitations). Instead, images need to be converted to base64 and inlined into the HTML.
Page margins
On iOS you can set the page margins using the margins option:
const { uri } = await Print.printToFileAsync({ html: 'This page is printed with margins', margins: { left: 20, top: 50, right: 20, bottom: 100, }, });
If useMarkupFormatter is set to true, setting margins may cause a blank page to appear at the end of your printout. To prevent this, make sure your HTML string is a well-formed document, including <!DOCTYPE html> at the beginning of the string.
On Android, if you're using html option in printAsync or printToFileAsync, the resulting print might contain page margins (it depends on the WebView engine).
They are set by @page style block and you can override them in your HTML code:
<style> @page { margin: 20px; } </style>
See @page documentation on MDN for more details.