GithubHelp home page GithubHelp logo

thepowerofswift / uiimagepluspdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dimamishchenko/uiimagepluspdf

0.0 0.0 0.0 255 KB

UIImage PDF extensions.

License: MIT License

Swift 96.05% Ruby 3.95%

uiimagepluspdf's Introduction

UIImagePlusPDF

Swift 4.2 CocoaPods compatible Packagist

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:

pod 'UIImagePlusPDF'

#for swift less than 4.2 use:
pod 'UIImagePlusPDF', '~> 1.0.1'
import UIImagePlusPDF

Usage

Simple example:

let imageView = UIImageView()
let image = UIImage.pdfImage(with: "imageName")
imageView.image = image

Other options

//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:

//using NSCache
//default is true
UIImage.pdfCacheInMemory = true

Disk cache:

//default is false
UIImage.pdfCacheOnDisk = true

Cache deleting:

//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: CGSize(width: usedWidth, height: usedHeight), 
    pageNumber: 1 /*optional, default is 1*/
)

//memory cached pdf with url
UIImage.removeMemoryCachedPDFImage(
    with: URL(string: "path"), 
    size: CGSize(width: usedWidth, height: usedHeight), 
    pageNumber: 1 /*optional, default is 1*/
)

//disk cached pdf with name
UIImage.removeDiskCachedPDFImage(
    with: "pdf name", 
    size: CGSize(width: usedWidth, height: usedHeight), 
    pageNumber: 1 /*optional, default is 1*/
)

//disk cached pdf with url
UIImage.removeDiskCachedPDFImage(
    with: URL(string: "path"), 
    size: CGSize(width: usedWidth, height: usedHeight), 
    pageNumber: 1 /*optional, default is 1*/
)

License

UIImagePlusPDF is under MIT license. See the LICENSE file for more info.

uiimagepluspdf's People

Contributors

dimamishchenko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.