kisimediaDE/cap-printer
Capacitor plugin for printing PDF documents - both local and remote.
npm install cap-printer
npx cap syncPlugin interface for CapPrinter.
print(options: PrintRequest) => Promise<void>Print a PDF document from a remote URL or local file path.
Either url or localPath must be provided.
| Param | Type |
|---|---|
options |
PrintRequest |
isAvailable() => Promise<{ available: boolean; }>Returns whether the plugin is available on the current platform.
Returns: Promise<{ available: boolean; }>
Parameters for a print request.
| Prop | Type | Description |
|---|---|---|
url |
string |
Remote PDF file URL. Optional if localPath is provided. |
localPath |
string |
Local file path to a PDF document. Optional if url is provided. |
options |
PrintOptions |
Optional native print configuration. |
Optional print configuration for native print dialogs.
| Prop | Type | Description |
|---|---|---|
outputType |
'general' | 'photo' | 'grayscale' |
Defines the output quality or color mode. - general: Default system quality - photo: High-quality color/photo print - grayscale: Black & white / grayscale |
orientation |
'portrait' | 'landscape' |
Sets the page orientation. - portrait: Standard vertical layout - landscape: Horizontal layout |
duplex |
boolean |
Enables duplex printing if the printer supports it. |
import { CapPrinter } from 'cap-printer';
await CapPrinter.print({
url: 'https://example.com/your.pdf',
options: {
outputType: 'photo',
orientation: 'landscape',
duplex: true,
},
});import { CapPrinter } from 'cap-printer';
await CapPrinter.print({
localPath: '/path/to/your/file.pdf',
});import { CapPrinter } from 'cap-printer';
const { available } = await CapPrinter.isAvailable();
if (!available) {
console.warn('CapPrinter is not available on this platform.');
return;
}
await CapPrinter.print({ url: 'https://example.com/your.pdf' });βΉοΈ On Web,
isAvailable()always returnsfalse.
For a detailed list of changes and version history, check out the CHANGELOG.md.
Contributions are welcome!
If you'd like to improve the plugin, report an issue, or suggest a feature, feel free to open a pull request or create an issue.
This plugin is licensed under the MIT License.