Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DimaMishchenko/UIImagePlusPDF
UIImage PDF extensions.
https://github.com/DimaMishchenko/UIImagePlusPDF
Last synced: about 1 month ago
JSON representation
UIImage PDF extensions.
- Host: GitHub
- URL: https://github.com/DimaMishchenko/UIImagePlusPDF
- Owner: DimaMishchenko
- License: mit
- Created: 2018-05-16T13:03:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-27T15:29:44.000Z (about 4 years ago)
- Last Synced: 2024-12-01T04:21:39.584Z (about 1 month ago)
- Language: Swift
- Size: 250 KB
- Stars: 36
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - UIImagePlusPDF - UIImage extensions to simply use PDF files. (Media / PDF)
- awesome-ios-star - UIImagePlusPDF - UIImage extensions to simply use PDF files. (Media / PDF)
README
# UIImagePlusPDF
[![Swift 4.2](https://img.shields.io/badge/Swift-5.3-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![CocoaPods compatible](https://img.shields.io/cocoapods/v/UIImagePlusPDF.svg)](https://cocoapods.org/pods/UIImagePlusPDF)
[![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)]()UIImage extensions to use PDF files.
Using `UIImagePlusPDF` you can avoid a lot `png` images files (1x, 2x, 3x sizes) and simply replace each of them with only one `pdf` file.## Installation
[CocoaPods](http://www.cocoapods.org):
``` ruby
pod 'UIImagePlusPDF'
`````` swift
import UIImagePlusPDF
```## Usage
**Simple example:**
``` swift
let imageView = UIImageView()
let image = UIImage.pdfImage(with: "imageName")
imageView.image = image
```
**Other options**
``` swift
//with custom width
UIImage.pdfImage(with: "imageName", width: 350)//with custom height
UIImage.pdfImage(with: "imageName", height: 350)//with custom size
UIImage.pdfImage(with: "imageName", size: CGSize(width: 300, height: 400))//with page number
UIImage.pdfImage(with: "multipage pdf file", width: 300, pageNumber: 2)//same options with resource url
UIImage.pdfImage(with: URL(string: "path"))
```## Cache
**Memory cache:**
``` swift
//using NSCache
//default is true
UIImage.pdfCacheInMemory = true
```
**Disk cache:**
``` swift
//default is false
UIImage.pdfCacheOnDisk = true
```
**Cache deleting:**
``` swift
//all cache
UIImage.removeAllPDFCache()//all memory cache
UIImage.removeAllPDFMemoryCache()//all disk cache
UIImage.removeAllPDFDiskCache()//memory cached pdf with name
UIImage.removeMemoryCachedPDFImage(
with: "pdf name",
size: imageSize,
pageNumber: 1 /*optional, default is 1*/
)//memory cached pdf with url
UIImage.removeMemoryCachedPDFImage(
with: URL(string: "path"),
size: imageSize,
pageNumber: 1 /*optional, default is 1*/
)//disk cached pdf with name
UIImage.removeDiskCachedPDFImage(
with: "pdf name",
size: imageSize,
pageNumber: 1 /*optional, default is 1*/
)//disk cached pdf with url
UIImage.removeDiskCachedPDFImage(
with: URL(string: "path"),
size: imageSize,
pageNumber: 1 /*optional, default is 1*/
)
```
## License
**UIImagePlusPDF** is under MIT license. See the [LICENSE](LICENSE) file for more info.