Latest 0.2.0
Homepage https://github.com/WeirdMath/SwiftyHaru
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0, watchos 2.0
Authors

Build Status
codecov
Codacy Badge
codebeat badge
Language
Platform
Cocoapods

SwiftyHaru is an object-oriented Swift wrapper for LibHaru, a C library for creating PDF documents. It brings the safety of Swift itself to the process of creating PDFs on different platforms like Linux, macOS, iOS, watchOS and tvOS.

Check out which features of LibHaru has already been implemented in FEATURES.md

Requirements

  • Swift 3.1+
  • iOS 8.0+
  • macOS 10.10+
  • tvOS 9.0+
  • watchOS 2.0+
  • Ubuntu 14.04+

Installation

CocoaPods

For the latest release in CocoaPods add the following to your Podfile:

use_frameworks!

pod 'SwiftyHaru'

For the latest dev build:

use_frameworks!

pod 'SwiftyHaru', :git => 'https://github.com/WeirdMath/SwiftyHaru.git', :branch => 'dev'

Swift Package Manager

Add SwiftyHaru as a dependency to your Package.swift. For example:

let package = Package(
    name: "YourPackageName",
    dependencies: [
        .Package(url: "https://github.com/WeirdMath/SwiftyHaru.git", majorVersion: 0)
    ]
)

Important: when building your project that has SwiftyHaru as a dependency,
you need to pass the -Xlinker -lz flags to the compiler. This is because SwiftyHaru has to be linked with zlib (which must be intalled on your computer). For example:

$ swift build -Xlinker -lz
$ swift test -Xlinker -lz

Documentation

Available here.

Getting started

import SwiftyHaru

// Initialize stuff
let document = PDFDocument()
let page = document.addPage(width: 600, height: 400)

// Construct a path
let path = Path()
    .moving(toX: 100, y: 100)
    .appendingLine(toX: 400, y: 100)
    .moving(toX: 500, y: 200)
    .appendingArc(x: 400, y: 200, radius: 100, beginningAngle: 90, endAngle: 180)
    .appendingCircle(x: 200, y: 200, radius: 50)
    .moving(toX: 500, y: 200)
    .appendingCurve(controlPoint1: Point(x: 400, y: 200),
                    controlPoint2: Point(x: 400, y: 300),
                    endPoint: Point(x: 500, y: 300))
    .closingSubpath()

// Paint the path
page.draw { context in

    context.strokeColor = .blue
    context.stroke(path)
}

// Put some text
page.draw { context in
    context.show(text: "Roses are red,nViolets are blue,nSugar is sweet,nAnd so are you.",
                 atX: 300, y: 200)
}

Contributing

Building:

$ make debug

Or:

$ make release

Testing:

$ make test

Generating Xcode project

Since the Xcode project is explicitly gitignored, you might want to generate it in order to make development comfortable for you. This can be accomplished by running the following command:

make generate-xcodeproj

Latest podspec

{
    "name": "SwiftyHaru",
    "version": "0.2.0",
    "summary": "Object-oriented and safe Swift wrapper for LibHaru u2014 a library for creating PDF documents",
    "description": "SwiftyHaru is an object-oriented Swift wrapper for LibHaru,na C library for creating PDF documents. It brings the safety of Swiftnitself to the process of creating PDFs on different platforms like Linux,nmacOS, iOS, watchOS and tvOS.",
    "homepage": "https://github.com/WeirdMath/SwiftyHaru",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Sergej Jaskiewicz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/WeirdMath/SwiftyHaru.git",
        "tag": "0.2.0"
    },
    "social_media_url": "https://twitter.com/broadway_lamb",
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "source_files": "Sources/**/*.{swift,h,c}",
    "public_header_files": [
        "Sources/CLibPNG/include/*.h",
        "Sources/CLibHaru/include/*.h"
    ],
    "private_header_files": [
        "Sources/CLibPNG/include/pngpriv.h",
        "Sources/CLibPNG/include/pnginfo.h",
        "Sources/CLibPNG/include/pngstruct.h"
    ],
    "libraries": "z",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This