https://github.com/mc-public/pdfpreviewer
A SwiftUI component for displaying PDF files.
https://github.com/mc-public/pdfpreviewer
pdfview swiftui swiftui-components
Last synced: 9 months ago
JSON representation
A SwiftUI component for displaying PDF files.
- Host: GitHub
- URL: https://github.com/mc-public/pdfpreviewer
- Owner: mc-public
- License: bsd-3-clause
- Created: 2025-02-11T13:57:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-11T14:40:10.000Z (over 1 year ago)
- Last Synced: 2025-02-11T15:30:02.093Z (over 1 year ago)
- Topics: pdfview, swiftui, swiftui-components
- Language: Swift
- Homepage:
- Size: 12.5 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### PDFPreviewer - a powerful SwiftUI view for iOS platform to display PDF files.
**PDFPreviewer** uses Apple's [PDFKit](https://developer.apple.com/documentation/pdfkit) to display PDF files. And it added features that were originally thought to be impossible within the framework.


## Features
- Smoothly display PDF files.
- Custom background color and page border.
- Custom page double-click operation.
- Automatically invert the PDF rendering tone in night mode.
- A very simple and powerful zoom-scale control system, allow auto scaling, fixed scaling ratio, or even disable scaling.
- A convenient and easy-to-use PDF page navigation system.
## Example
After downloading the package resources, open the test project to quickly test all the features provided by this framework. The following are two screenshots that demonstrate some of the features supported by the framework.

## Usage
#### Create a `PDFPreviewer` using the view model
```swift
import SwiftUI
import PDFPreviewer
struct ContentView: View {
static let TestPDFURL: URL = {
guard let pdfURL = Bundle.main.url(forResource: "Test", withExtension: "pdf") else {
fatalError()
}
return pdfURL
}()
@StateObject var controller = PDFPreviewerModel()
var body: some View {
PDFPreviewer(model: controller)
.task {
await controller.loadDocument(from: Self.TestPDFURL)
}
}
}
```
Ensure the uniqueness of the view model being passed, otherwise it will result in undefined behavior.
## Contributing
Clone this repository to get started working on the project.
```bash
git clone --recursive git@github.com:mc-public/PDFPreviewer.git
```