• Stars
    star
    119
  • Rank 288,203 (Top 6 %)
  • Language
    F#
  • License
    MIT License
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Builds PDF's from pure F# (and needs a more interesting name)

FsPdf

Builds PDF's from pure F# (and needs a more interesting name)

Build and Test FsPdf on Nuget

Generates PDF content to enable developers to build PDF's programatically. PDF's are helpful for offline documentation, printing, certificates of achievement, TPS reports, customer invoices, taxes, or being an actuary.

What works?

  • Makes a PDF without any extra dependencies (beyond a .NET Standard 2.0 runtime).
  • Simple page layout formatting.
  • Paths and shapes.
  • Formatted text.
  • A higher level DSL so you're not working with PDF primitives.
  • Word wrap - wraps at spaces between words (left aligned text).

What's in progress

  • A nicer DSL for building text without having to understand PDF instructions.

Then what?

  • Font embedding.
  • Images

Example

Here is an example of a PDF generated by this test.

F# API

A PdfFile type is the main type to create, and it contains document metadata as well as a "catalog" which holds the pages themselves. The catalog has a default page size that will apply to all pages unless they override it.

Each Page holds Resources (currently just fonts), the contents as a list of PDF stream instructions, and optionally can override the page media to have a different page size. Because the instructions themselves are low level, there are some helpful functions for building shapes, wrapping strings, etc.

The result looks roughly like this:

let pdf =
    {
        Catalog =
            {
                PageLayout = SinglePage
                DefaultMedia = Media.Letter
                Pages =
                    [
                        {
                            Resources =
                                Map.empty
                                |> Map.add "F1" (FontResource (Type1, "Helvetica"))
                            Contents =
                                [
                                    BeginText
                                    Leading (20)
                                    FontSize ("F1", 12.)
                                    NextLineTranslate (50, 600)
                                    ShowText "hello world"
                                    EndText
                                ]
                            MediaSize = Some (Letter)
                        }
                    ]
            }
        Info = None
    }

This creates a PDF with a single page. The page contains some text, set at 50 points from the left side and 600 points from the bottom of the page.

More Repositories

1

FSharp.Text.Docker

Build dockerfiles and run docker commands from F#
F#
57
star
2

FsCloudInit

Builds cloud-init VM configuration files in F#
F#
13
star
3

docker-fsharp-mono-netcore

Docker image for F# with mono and .NET Core toolchains
Dockerfile
12
star
4

Pengines.Client

F#
9
star
5

fwrules

Builds firewall rules from type safe policies
F#
4
star
6

suave-chiron-netcore

Basic use of Suave and Chiron running on the .NET Core runtime, including tests.
F#
4
star
7

openfsharp-resilient

Slides and source from OpenFSharp presentation on resilient F# in the Linux ecosystem
F#
4
star
8

openfsharp-logic

You Got Logic in my Functional Programming!
F#
3
star
9

autodevenv

Automation to install tools for a development environment.
3
star
10

corert-fsharp-example

Example working CoreRT application in F#
F#
2
star
11

dotnet-servicebus-template

AsyncAPI generator for service bus topologies
F#
2
star
12

ansiblefs

Writing Ansible modules in F#
F#
2
star
13

pokedata

Postgres database of Pokemon data imported from CSV.
Makefile
2
star
14

SoftwareSpecFsInteractive

Building a software spec with F# and .NET Interactive
Jupyter Notebook
2
star
15

dotnetConf2021

Code samples from .NET Conf 2021 with a focus on F#
F#
2
star
16

mono-in-docker

Tutorial for running mono applications in a docker container
1
star
17

FSharp.Text.Rpm

Build an RPM spec from F#
F#
1
star
18

FarmerServiceBusWithMsi

Farmer example for a deployment with a Service Bus application using managed identity
F#
1
star
19

azurts

Extending Azure alerts with webhook infrastructure
F#
1
star
20

DreamhostNetClient

.NET client for the Dreamhost API
F#
1
star
21

pengines-dockerfile

A Dockerfile for creating a SWI-Prolog Pengines Docker image
1
star
22

strace-concurrency

Tracing concurrency in F# and C#
F#
1
star
23

mongodb-rest

RESTful API for mongodb using twisted python
Python
1
star