Coder Social home page Coder Social logo

maxprig / swiftyharu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weirdmath/swiftyharu

0.0 2.0 0.0 3.92 MB

Object-oriented and safe cross-platform Swift wrapper for LibHaru — a library for creating PDF documents.

Home Page: https://weirdmath.github.io/SwiftyHaru/

License: MIT License

Ruby 0.21% Swift 5.50% Shell 0.06% C 94.04% Objective-C 0.05% C++ 0.14%

swiftyharu's Introduction

SwiftyHaru

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
  • iOS 8.0+
  • OSX 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)
    ]
)

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 in macOS:

$ swift build -Xlinker -lz

Testing in macOS:

$ swift test -Xlinker -lz

Building in Ubuntu:

$ swift build -Xlinker -rpath=.build/debug/ -Xlinker -lz

Testing in Ubuntu:

$ swift test -Xlinker -rpath=.build/debug/ -Xlinker -lz

swiftyharu's People

Contributors

broadwaylamb avatar

Watchers

 avatar  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.