Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danielsaidi/printingkit
PrintingKit is a Swift SDK that helps you print images, strings, views, PDFs etc. in Swift and SwiftUI.
https://github.com/danielsaidi/printingkit
ios ipados macos pdf print printer swift swiftui tvos visionos watchos
Last synced: 7 days ago
JSON representation
PrintingKit is a Swift SDK that helps you print images, strings, views, PDFs etc. in Swift and SwiftUI.
- Host: GitHub
- URL: https://github.com/danielsaidi/printingkit
- Owner: danielsaidi
- License: mit
- Created: 2023-08-21T11:30:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-12T16:25:38.000Z (11 months ago)
- Last Synced: 2024-05-01T18:07:51.931Z (9 months ago)
- Topics: ios, ipados, macos, pdf, print, printer, swift, swiftui, tvos, visionos, watchos
- Language: Swift
- Homepage:
- Size: 3.5 MB
- Stars: 69
- Watchers: 5
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
## About PrintingKit
PrintingKit is a Swift SDK that helps you print images, strings, views, PDFs etc. in Swift and SwiftUI.
With PrintingKit, you just have to create a `Printer` instance, or use `Printer.shared`, then use it to print any of these supported `PrintItem` types:
* `.attributedString(_:configuration:)` - an attributed string.
* `.imageData(_:)` - JPG or PNG data.
* `.imageFile(at:)` - a JPG or PNG file at a certain URL.
* `.pdfData(_:)` - PDF document data.
* `.pdfFile(at:)` - a PDF document file at a certain URL.
* `.string(_:configuration:)` - a plain string.
* `.view(_:withScale:)` - a SwiftUI view.More types can be added in the future. Feel free to contribute if you have a new type that you'd like to support.
## Installation
PrintingKit can be installed with the Swift Package Manager:
```
https://github.com/danielsaidi/PrintingKit.git
```## Getting started
To print any of supported print item type, just create a `Printer` instance, or use `Printer.shared`:
```swift
struct MyView: View {let printer = Printer.shared
var body: some View {
VStack {
Button("Print PDF") {
try? printer.print(.pdf(at: anyUrl))
}
Button("Print view") {
try? printer.print(image)
}
Button("Print view without try") {
printer.printInTask(image)
}
}
}
}
```See the online [getting started guide][Getting-Started] for more information.
## Documentation
The online [documentation][Documentation] has more information, articles, code examples, etc.
## Demo Application
The `Demo` folder has an app that lets you explore the library.
## Support my work
You can [sponsor me][Sponsors] on GitHub Sponsors or [reach out][Email] for paid support, to help support my [open-source projects][OpenSource].
Your support makes it possible for me to put more work into these projects and make them the best they can be.
## Contact
Feel free to reach out if you have questions or if you want to contribute in any way:
* Website: [danielsaidi.com][Website]
* Mastodon: [@[email protected]][Mastodon]
* Twitter: [@danielsaidi][Twitter]
* E-mail: [[email protected]][Email]## License
PrintingKit is available under the MIT license. See the [LICENSE][License] file for more info.
[Email]: mailto:[email protected]
[Website]: https://danielsaidi.com
[GitHub]: https://github.com/danielsaidi
[Twitter]: https://twitter.com/danielsaidi
[Mastodon]: https://mastodon.social/@danielsaidi
[OpenSource]: https://danielsaidi.com/opensource
[Sponsors]: https://github.com/sponsors/danielsaidi[Documentation]: https://danielsaidi.github.io/PrintingKit
[Getting-Started]: https://danielsaidi.github.io/PrintingKit/documentation/printingkit/getting-started[License]: https://github.com/danielsaidi/PrintingKit/blob/master/LICENSE