Skip to content
Shiny.NET

Printing | Platform Setup

Info.plist:

<!-- Bluetooth LE printers -->
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Prints receipts to nearby Bluetooth printers</string>
<!-- WiFi printers -->
<key>NSLocalNetworkUsageDescription</key>
<string>Finds and prints to receipt printers on your network</string>
<key>NSBonjourServices</key>
<array>
<string>_pdl-datastream._tcp</string>
<string>_printer._tcp</string>
</array>

Both network entries are required from iOS 14. Without the NSBonjourServices types the mDNS browse silently returns nothing, and without NSLocalNetworkUsageDescription iOS blocks the TCP connection to the printer as well - even when you connect by IP address. Add any vendor-specific type you pass to INetworkPrinterScanner.Scan(type).

AirPrint (native printing) needs nothing. A sandboxed Mac Catalyst app also needs com.apple.security.network.client and com.apple.security.device.bluetooth.

The same Info.plist keys as iOS. A sandboxed app needs these entitlements:

<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.device.bluetooth</key>
<true/>
<!-- native printing goes through CUPS, which the sandbox blocks without this -->
<key>com.apple.security.print</key>
<true/>
<!-- Bluetooth LE printers (API 31+) -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- WiFi printers -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

See BluetoothLE for the pre-Android 12 permissions. mDNS goes through NsdManager, so no multicast lock is needed.

Native printing needs no permission. It hosts the system print dialog on the app’s current activity, so print while the app is in the foreground. With no activity at all - a print issued from a background service before any UI has been created - Print returns Failed.

Nothing to declare for Bluetooth or TCP printing in an unpackaged app; a packaged app needs the bluetooth and privateNetworkClientServer capabilities. Native PDF printing uses the shell verb of whichever app is registered for .pdf.

  • Bluetooth LE - register AddBluetoothLE() from Shiny.BluetoothLE.Linux before AddBluetoothLePrinting().
  • Native printing - needs the CUPS client tools (lp, lpstat - the cups-client package on Debian / Ubuntu).
  • Rendering - add SkiaSharp.NativeAssets.Linux to the app when using Shiny.Printing.Rendering. SkiaSharp’s plain net10.0 build only carries the macOS and Windows natives.
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="4.151.1" />

The browser transports need a Chromium browser and a secure context (HTTPS or localhost). Nothing to configure in the app - the JavaScript modules ship as static web assets of the Razor class libraries.