Print.printToFileAsync HTML to PDF adds an extra blank page at the end
See original GitHub issue🐛 Bug Report
Environment
Expo CLI 3.15.5 environment info:
System:
OS: macOS 10.15.3
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.14.0 - /usr/local/bin/node
npm: 6.14.3 - /usr/local/bin/npm
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.4/11N132i - /usr/bin/xcodebuild
npmPackages:
expo: ~36.0.0 => 36.0.2
react: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4
npmGlobalPackages:
expo-cli: 3.15.5
Observed in iOS, Snack confirms the issue in Android too. Web looks fine.
Steps to Reproduce
This code creates an extra page at the end that is blank.
const filePath = await Print.printToFileAsync({
html: 'hello',
base64: false
})
Sharing.shareAsync(filePath.uri)
I applied CSS for html such as
<html><head><style>@page { margin: 20px; height: 90%} html,body {height: 90%;} </style></head><body>hello</body></html>
but the blank page is there.
Also note that the images can be broken mid-page, half printed on page N, another half on page N+1 even with page-break-inside:avoid; (probably a separate issue)
Expected Behavior
No unwanted blank page at the end
Actual Behavior
See the blank page at the end even though I just printed a single word. B3662F39-75CF-4D3D-B6A4-C610B52A5447.pdf
Reproducible Demo
See the code above or the Snack https://snack.expo.io/r1IBgIW2B
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
css - how to avoid extra blank page at end while printing?
I had this issue, because i was setting html height to 101% to force a scrollbar to always show. (Eliminates the jump between...
Read more >Print - Expo Documentation
Prints a document or HTML, on web this prints the HTML from the page. Note: On iOS, printing from HTML source doesn't support...
Read more >Stop blank page being created (because of page break setting ...
To fix this just change it to page-break-after:auto. It will break correctly and not create an extra blank page. So, try changing your...
Read more >How to avoid an extra blank page - Google Groups
I'm trying to get a PDF with this command: "/usr/bin/wkhtmltopdf ... If I print this from Chrome, it displays ready-to-print one page, ...
Read more >@expo/config-plugins | Yarn - Package Manager
This is the log of notable changes to the Expo client that are developer-facing. Package-specific changes not released in any SDK will be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ok, thanks. I did managed to modify your sample to highlight the different treatment that file:// uris get on iOS vs Android. See https://github.com/CapelliC/expo-print-test-pdf-file-uri-missing-ios.
Opened an issue at https://github.com/expo/expo/issues/7940
It’s worked for me too, thankssss !!!