Latest 1.0.19
Homepage https://github.com/wirawansanusi/WSPagePreview
License Apache-2.0
Platforms ios 8.0, requires ARC
Authors

CI Status
Version
License
Platform

Introduction

alt text alt text alt text

WSPagePreview lets you to create a customizable page preview with additional options like page size, margin and font size.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

iOS 7.0+

Installation

WSPagePreview is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "WSPagePreview"

How to use

1) Create and link IBOutlet scrollView and var WSPagePreview

@IBOutlet weak var scrollView: UIScrollView!
var pagePreview: WSPagePreview?

2) Inside viewDidLoad function, init and add a delegate (don’t forget to include WSPagePreviewDelegate)

// Convenience init with default settings (Paper size: A4, Margin: 0 cm)
pagePreview = WSPagePreview()

// Default init requires you to specify the paper size and page margin
// pagePreview = WSPagePreview(pageSize: CGSize, pageMargin: UIEdgeInsets, fontSize: CGFloat)

pagePreview?.delegate = self

3) Inside viewDidLayoutSubviews function, call the initDefaultSettings(UIScrollView)

pagePreview?.initDefaultSettings(scrollView)

4) Implement this delegate method

func WSPagePreviewSetTextContent(pagePreview: WSPagePreview) -> String {

    // Do your text processing here

    return text
}

5) Done! or do you want more? See the customize page option below!

(Optional) Customize Page Option

In case you need to customize some properties to adjust with your preferences, you can use this helpful method! Ideally, you should call all of this available function right after initDefaultSettings(UIScrollView) inside the viewDidLayoutSubviews function.

To show a page control

func WSPagePreviewShowPageControl(pagePreview: WSPagePreview, pageControl: UIPageControl) {

    // Do your page control styling here
    ...

    view.addSubview(pageControl)
}

To set custom margin

let margin = UIEdgeInsetsMake(20.0, 20.0, 20.0, 20.0)
pagePreview?.setPageMargin(margin)

To set custom horizontal margin

pagePreview?.setPageMarginHorizontally(20.0, right: 20.0)

To set custom vertical margin

pagePreview?.setPageMarginVertically(20.0, bottom: 20.0)

To set custom page size

let size = CGSize(width: 500.0, height: 500.0)
pagePreview?.setPageSize(size)

To set custom font size

pagePreview?.setFontSize(14.0)
*Psstt! WSPagePreview automatically adjust the font size based on paper size so you don’t have to worry about that, you’re welcome!

Unknown behavior / bug

  • Size classes besides iphone (Not tested yet)
  • Programmatically scrollView (Not tested yet)
  • Landscape mode (Not working)
  • …?

Author

Wirawan Sanusi, [email protected] (http://www.wirawansanusi.com)

License

WSPagePreview is available under the Apache License 2.0 (Apache-2.0). See the LICENSE file for more info.

Latest podspec

{
    "name": "WSPagePreview",
    "version": "1.0.19",
    "summary": "WSPagePreview lets you to create a customisable page preview with additional options like page size, margin and font size.",
    "description": "Create a customizable page preview without any trouble!n                        Supports :n                        - Auto Layoutn                        - Storyboardn                        - iOS 7.0+",
    "homepage": "https://github.com/wirawansanusi/WSPagePreview",
    "screenshots": [
        "http://i.imgur.com/qdndBZq.png",
        "http://i.imgur.com/VPPARlx.png",
        "http://i.imgur.com/H5h6Qu1.png"
    ],
    "license": "Apache-2.0",
    "authors": {
        "wirawansanusi": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wirawansanusi/WSPagePreview.git",
        "tag": "1.0.19"
    },
    "social_media_url": "http://www.wirawansanusi.com/",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "WSPagePreview": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This