-
Notifications
You must be signed in to change notification settings - Fork 273
iOS 16.4 printing - background graphics support #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
iOS 16.4 add property to allow background graphics when printing the web page. Default value is false, so I need to do this change to allow background graphics.
Only set shouldPrintBackgrounds by options.
Thank you for finding this! It was driving me mad and I'd not discovered the cause myself. 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having applied this to a project locally I've got a couple of suggested fixes (it didn't work applied as-is).
|
||
if (@available(iOS 16.4, *)) { | ||
if (options[@"backgroundGraphics"]) { | ||
_webView.configuration.preferences.shouldPrintBackgrounds = [options[@"backgroundGraphics"] boolValue]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the option should be converted via RCTConvert
.
_webView.configuration.preferences.shouldPrintBackgrounds = [options[@"backgroundGraphics"] boolValue]; | |
_webView.configuration.preferences.shouldPrintBackgrounds = [RCTConvert BOOL:options[@"backgroundGraphics"]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, [WKWebView configuration]
should only be accessed from the main thread.
_webView.configuration.preferences.shouldPrintBackgrounds = [options[@"backgroundGraphics"] boolValue]; | |
dispatch_sync(dispatch_get_main_queue(), ^{ | |
_webView.configuration.preferences.shouldPrintBackgrounds = [RCTConvert BOOL:options[@"backgroundGraphics"]]; | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for saving my day 🥳
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
iOS 16.4 add property to allow background graphics when printing the web page. Default value is false, so I need to do this change to allow background graphics.
There is a link to Apple change log.