Smart WebView supports printing the content currently displayed in the WebView using the native platform’s print framework.
How to Trigger Printing
Printing is typically initiated from your web content by using a hyperlink with a special URL scheme: print:
.
HTML Example (Platform Agnostic):
<a href="print:">Print this Page</a>
<button onclick="window.location.href='print:'">Print Report</button>
How it Works
1. User clicks a `print:` link.
2. `shouldOverrideUrlLoading` in `MainActivity.java`'s `Callback` intercepts the URL.
3. It calls `Functions.print_page`.
4. `Functions.print_page` uses the Android `PrintManager` service.
5. It creates a `PrintDocumentAdapter` from the main `WebView` (`SmartWebView.asw_view`).
6. It starts a print job, potentially setting default attributes.
7. The standard Android print preview screen appears, allowing printer selection (including Save as PDF) and settings adjustment.
```md
```
The quality and layout of the printout depend heavily on how well the webpage's CSS is optimized for print media (`@media print`).
Requirements
* Android 4.4 (KitKat, API 19) or higher.
* Device must have print services enabled/configured (e.g., Cloud Print, Wi-Fi Direct, Save as PDF).
* Relies on UIKit's printing framework.
* Device must have AirPrint printers available on the network or support other printing methods (like Save to Files).
No specific configuration variables in SmartWebView.java
are needed for this feature on Android; it relies on intercepting the print:
URL scheme.