SyntaxSolutions.PdfBuilder 1.0.0-beta

This is a prerelease version of SyntaxSolutions.PdfBuilder.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package SyntaxSolutions.PdfBuilder --version 1.0.0-beta
NuGet\Install-Package SyntaxSolutions.PdfBuilder -Version 1.0.0-beta
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SyntaxSolutions.PdfBuilder" Version="1.0.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SyntaxSolutions.PdfBuilder --version 1.0.0-beta
#r "nuget: SyntaxSolutions.PdfBuilder, 1.0.0-beta"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SyntaxSolutions.PdfBuilder as a Cake Addin
#addin nuget:?package=SyntaxSolutions.PdfBuilder&version=1.0.0-beta&prerelease

// Install SyntaxSolutions.PdfBuilder as a Cake Tool
#tool nuget:?package=SyntaxSolutions.PdfBuilder&version=1.0.0-beta&prerelease

PDF Builder .Net

A simple .Net library used to create portable document format (PDF) documents.

Features

  1. Two built in fonts 'Arial' and 'Times New Roman'
  2. Methods to easily add a page title, heading, text, paragraph and image to a document
  3. Support for all standard page sizes and orientations
  4. Page coorindates and sizes specified in millimetres (mm)
  5. Support for page headers and footers

Installation

PM> Install-Package SyntaxSolutions.PdfBuilder

Example

using SyntaxSolutions.PdfBuilder;

private void PageHeader(PdfBuilder builder, PageHeaderEventArgs e)
{
    builder.AddText("...PAGE HEADER...");
    builder.NewLine();
}

private void PageFooter(PdfBuilder builder, PageFooterEventArgs e)
{
    var postionY = builder.PagePositionY; 
    builder.PagePositionY = 10; 
    builder.AddText(String.Format("...PAGE FOOTER... | Page: {0}", builder.PageCount.ToString()));
    builder.PagePositionY = postionY;
}

var options = new DocumentOptions()
{
    PageSize = PageSize.A4,
    PageOrientation = PageOrientation.Portrait
};
var builder = new PdfBuilder(options);

builder.PageHeader += new PageHeaderEventHandler(this.PageHeader);
builder.PageFooter += new PageFooterEventHandler(this.PageFooter);

builder.Open();

builder.NewPage();
builder.AddTitle("Page Title");
builder.NewLine();

builder.AddHeading("Font Styles");
builder.AddText("Times New Roman - Normal");
builder.NewLine();

builder.AddText("Times New Roman - Bold", TextOptions.Set(FontWeight: TextFontWeight.Bold));

builder.NewLine();

builder.AddText("Times New Roman - Italic", TextOptions.Set(FontStyle: TextFontStyle.Italic));
builder.NewLine();

builder.AddText("Times New Roman - Italic Bold", TextOptions.Set(FontStyle: TextFontStyle.Italic, FontWeight: TextFontWeight.Bold));
builder.NewLine();

builder.AddText("Arial - Normal", TextOptions.Set(FontFamily: TextFontFamily.Arial));
builder.NewLine();

builder.AddText("Arial - Bold", TextOptions.Set(FontFamily: TextFontFamily.Arial, FontWeight: TextFontWeight.Bold));
builder.NewLine();

builder.AddText("Arial - Italic", TextOptions.Set(FontFamily: TextFontFamily.Arial, FontStyle: TextFontStyle.Italic));
builder.NewLine();

builder.AddText("Arial - Italic Bold", TextOptions.Set(FontFamily: TextFontFamily.Arial, FontStyle: TextFontStyle.Italic, FontWeight: TextFontWeight.Bold));
builder.NewLine();
builder.NewLine();

builder.AddHeading("Colors");
builder.AddText("Red", TextOptions.Set(FontColor: Color.Red));
builder.NewLine();
builder.AddText("Green", TextOptions.Set(FontColor: Color.Green));
builder.NewLine();
builder.AddText("Blue", TextOptions.Set(FontColor: Color.Blue));
builder.NewLine();

builder.NewPage();
builder.NewLine();
builder.AddTitle("Paragraphs");
builder.NewLine();

builder.AddHeading("Left Aligned");
builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
builder.NewLine();

builder.AddHeading("Center Aligned");
builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", ParagraphOptions.Set(TextAlignment: TextAlignment.Center));
builder.NewLine();

builder.AddHeading("Right Aligned");
builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", ParagraphOptions.Set(TextAlignment: TextAlignment.Right));
builder.NewLine();

builder.AddHeading("Justified Aligned");
builder.AddParagraph("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", ParagraphOptions.Set(TextAlignment: TextAlignment.Justify));
builder.NewLine();

builder.NewPage();
builder.NewLine();
builder.AddTitle("Images");
builder.NewLine();

string imagepath = @"Sunset.jpg";
builder.AddImage(imagepath, 50);
builder.NewLine();

builder.AddImage(imagepath, 100);
builder.NewLine();

builder.AddImage(imagepath, 150);
builder.NewLine();

// save file 
var guid = System.Guid.NewGuid();
string filepath = "Test.pdf";

using (var fileStream = new FileStream(filepath, FileMode.Create, FileAccess.Write))
{
    byte[] data = builder.GetBytes();
    fileStream.Write(data, 0, data.Length);
}

builder.Close();

Product Compatible and additional computed target framework versions.
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5.2

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-rc 164 8/11/2021
1.0.0-beta 166 1/27/2021

A simple .Net library used to generate PDF files