MyNixOS website logo
Description

PDF backend for diagrams drawing EDSL.

This package provides a modular backend for rendering diagrams created with the diagrams EDSL to PDF files. It uses HPDF making it suitable for use on any platform.

It is a very preliminary version where only the diagrams Logo generation has been tested.

The package provides the following modules:

  • Diagrams.Backend.Pdf.CmdLine - if you're just getting started with diagrams, begin here.

  • Diagrams.Backend.Pdf - look at this next. The general API for the HPDF backend.

Additional documentation can be found in the README file distributed with the source tarball

diagrams-pdf is a an HPDF backend for diagrams. Diagrams is a powerful, flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language.

diagrams-pdf is a work in progress, and some features are not implemented yet. However, it is functional enough.

Installation

cabal update && cabal install diagrams-pdf

Usage

A simple example that uses diagrams-pdf to draw a square.

import Diagrams.Prelude
import Diagrams.Backend.Pdf.CmdLine

b1 = square 20 # lw 0.002

main = defaultMain (pad 1.1 b1)

Save this to file named Square.hs and compile this program:

ghc --make Square.hs

This will generate an executable which, when run produces a Pdf file. Run the executable with the --help option to find out more about how to call it.

$ ./Square --help
Command-line diagram generation.

Square [OPTIONS]

Common flags:
  -w --width=INT    Desired width of the output image (default 400)
  -h --height=INT   Desired height of the output image (default 400)
  -o --output=FILE  Output file
  -c --compressed   Compressed PDF file
  -? --help         Display help message
  -V --version      Print version information

You must pass an output file name with a .pdf extension to generate the PDF file.

$ ./Square -o square.pdf

Limitations

Two goals of the HPDF library were : powerful typesetting and no dependence on the OS libraries (for better portability). But, HPDF was also my first big library mainly done to learn. So I had to limit myself.

As a consequence, HPDF is only using the standard fonts defined in the PDF specification. It is not (yet) possible to include and use any other fonts.

So, for diagrams it is causing a problem : the face setting has nearly no meaning. Face is currently selected from the Italic and Oblique settings. Times is the default but when oblique is chosen, Helvetica is used.

I hope to improve this in future releases.

Here is a list of the fonts in HPDF:

  • Helvetica
  • Helvetica_Bold
  • Helvetica_Oblique
  • Helvetica_BoldOblique
  • Times_Roman
  • Times_Bold
  • Times_Italic
  • Times_BoldItalic
  • Courier
  • Courier_Bold
  • Courier_Oblique
  • Courier_BoldOblique
  • Symbol
  • ZapfDingbats.
Metadata

Version

0.3.1

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows