FsPdf 0.0.2
dotnet add package FsPdf --version 0.0.2
NuGet\Install-Package FsPdf -Version 0.0.2
<PackageReference Include="FsPdf" Version="0.0.2" />
paket add FsPdf --version 0.0.2
#r "nuget: FsPdf, 0.0.2"
// Install FsPdf as a Cake Addin #addin nuget:?package=FsPdf&version=0.0.2 // Install FsPdf as a Cake Tool #tool nuget:?package=FsPdf&version=0.0.2
FsPdf
Builds PDF's from pure F# (and needs a more interesting name)
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.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- FSharp.Core (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.