Latest 1.0.19
License Apache-2.0
Platforms ios 8.0, requires ARC

CI Status


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.


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


iOS 7.0+


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)


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


To set custom margin

let margin = UIEdgeInsetsMake(20.0, 20.0, 20.0, 20.0)

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)

To set custom font size

*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)
  • …?


Wirawan Sanusi, [email protected] (


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": "",
    "screenshots": [
    "license": "Apache-2.0",
    "authors": {
        "wirawansanusi": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.19"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "WSPagePreview": [

Pin It on Pinterest

Share This