Coder Social home page Coder Social logo

weirdmath / swiftyharu Goto Github PK

View Code? Open in Web Editor NEW
55.0 3.0 11.0 6.05 MB

A safe cross-platform Swift wrapper for LibHaru — a library for creating PDF documents.

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

License: MIT License

Swift 7.45% C 92.15% Objective-C 0.30% Shell 0.05% Ruby 0.03% Makefile 0.02%
swift pdf pdf-generation ios linux libharu cocoapods

swiftyharu's Introduction

SwiftyHaru

Build Status codecov documentation 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 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 4.2+
  • 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", from: "0.3.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()

try document.addPage(width: 600, height: 400) { context in

    // 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
    context.strokeColor = .blue
    context.stroke(path)

    // Put some text
    context.textLeading = 11
    try 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

swiftyharu's People

Contributors

broadwaylamb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swiftyharu's Issues

Package has unsupported layout for linux

Description

Getting a the package has an unsupported layout error when swift build

error: the package has an unsupported layout, modulemap (*****/Project/.build/checkouts/SwiftyHaru.git--4030071447907157648/Sources/CLibPNG/module.modulemap) is not allowed to be mixed with sources
fix: move the modulemap inside include directory

Steps To Reproduce

My Package.swift

import PackageDescription

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

In terminal, run command

swift build -Xlinker -lz

Swift Version

Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Target: x86_64-apple-macosx10.9

trying to use this in a iOS 12.1 environment - getting an issue when I try and compile.

getting ->
Undefined symbols for architecture arm64:
"_png_init_filter_functions_neon", referenced from:
_png_init_filter_functions in pngrutil.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

seems to defined in pngpriv.h. -> line 140

Any suggestions are welcomed.

Implement high-level grid drawing

Grid drawing must be highly customizable yet easy to use.

The user must be able to set:

  • The spacing between major lines (vertical and horizontal).
  • The spacing between minor lines (vertical and horizontal).
  • The order in which to draw the major lines (vertical first or horizontal first).
  • The order in which to draw the minor lines (vertical first or horizontal first).
  • The width and the color of all the major and minor lines.
  • The serifs' frequency, thickness, lengh and color. Serifs can be put on top, bottom, left and/or right edge of a grid.
  • The sequences of labels to place on top, bottom, left and/or right edge of a grid.
  • The labels' frequency, font, font size, color and offset.
  • The size of the grid itself.

Other objectives:

  • Write tests.
  • Make the grid beautiful.

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.