Code Monkey home page Code Monkey logo

gutenex's Introduction

Gutenex

Build Status

PDF generation!

So weird that it's still a thing for murderers in horror movies to keep clippings of their crimes. PDF that shit! โ€” Julieanne Smolinkski

What started out as a wrapper for the Erlang erlguten library has turned into a full rewrite in Elixir.

Plan

Rewriting the basic PDF functionality means:

  • text
  • fonts
  • images
  • rendering/exporting
  • parsing existing PDFs
  • templating
  • documentation

Usage

  # Load image, get alias
  {alpaca_alias, alpaca_rendition} = Gutenex.PDF.Images.load("./test/support/images/alpaca.png")

  {:ok, pid} = Gutenex.start_link
  Gutenex.add_image(pid, alpaca_alias, alpaca_rendition)
    |> Gutenex.begin_text
    |> Gutenex.set_font("Helvetica", 48)
    |> Gutenex.text_position(40, 180)
    |> Gutenex.text_render_mode(:fill)
    |> Gutenex.write_text("ABC")
    |> Gutenex.set_font("Courier", 32)
    |> Gutenex.text_render_mode(:stroke)
    |> Gutenex.write_text("xyz")
    |> Gutenex.end_text
    |> Gutenex.move_to(400, 20)
    |> Gutenex.draw_image(alpaca_alias, %{
      translate_x: 300,
      translate_y: 500,
    })
    |> Gutenex.export("./tmp/alpaca.pdf")
    |> Gutenex.stop

Now open up that file and you should see some text near the bottom and a picture of what I believe to be an alpaca. Could also be a llama.

By default, coordinates are in units of 1/72 inch as per the PDF spec. Origin is in lower left corner of the page. This is roughly 1 point in printing terms.

  Gutenex.line_width(pid, 0.01)          # very fine line
  |> Gutenex.line({{0, 0}, {500, 500}})  # up and to the right

gutenex's People

Contributors

edebill avatar esdrasedu avatar lowks avatar stocks29 avatar tyre 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.