Synercoding.FileFormats.Pdf 1.0.0-alpha001

This is a prerelease version of Synercoding.FileFormats.Pdf.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Synercoding.FileFormats.Pdf --version 1.0.0-alpha001                
NuGet\Install-Package Synercoding.FileFormats.Pdf -Version 1.0.0-alpha001                
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="Synercoding.FileFormats.Pdf" Version="1.0.0-alpha001" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Synercoding.FileFormats.Pdf --version 1.0.0-alpha001                
#r "nuget: Synercoding.FileFormats.Pdf, 1.0.0-alpha001"                
#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 Synercoding.FileFormats.Pdf as a Cake Addin
#addin nuget:?package=Synercoding.FileFormats.Pdf&version=1.0.0-alpha001&prerelease

// Install Synercoding.FileFormats.Pdf as a Cake Tool
#tool nuget:?package=Synercoding.FileFormats.Pdf&version=1.0.0-alpha001&prerelease                

FileFormats.Pdf

Build Status

This project was created to enable PDF creation on .NETStandard. This because multiple libraries did not suit my purpose of working on .NET Core & .NET Framework the same way. Some alternatives supported settings the different boxes (Media, Crop, Bleed & Trim) but did not fully supported images on all platforms. Others supported images but not the different boxes, and again others did not work at all on .NET Core.

Because of those reasons this libary was created.

License

This project is licensed under MIT license.

Specifications used

This library was created using the specifications lay out in "PDF 32000-1:2008, Document management – Portable document format – Part 1: PDF 1.7".

The full specifications are not implemented. This library currently only supports placements of images and setting the different boxes.

Remarks

Unlike most PDF libraries this library does not create the entire PDF model in memory before writing the PDF to a (file)stream. Most libaries support editing capabilities, because this libary only supports creating files, it was not necessary to keep the PDF model in memory. This results in less memory usage.

To place the images this library makes use of SixLabors/ImageSharp. All images that are placed in the PDF will be saved internally as a JPG file. This means that this library currently does NOT support transparency.

Output pdfs

The PDF files created in this library are PDF 1.7 compliant.

Sample program images

The sample project called Synercoding.FileFormats.Pdf.ConsoleTester uses multiple images. Those images were taken from Pexels.com and are licensed under the Pexels License.

Sample usage

using (var fs = File.OpenWrite(fileName))
using (var writer = new PdfWriter(fs))
{
    double _mmToPts(double mm) => mm / 25.4d * 72;

    writer
        .AddPage(page =>
        {
            var bleed = _mmToPts(3);
            // Mediabox = A4 Portrait with 3mm bleed all around
            page.MediaBox = new Primitives.Rectangle(0, 0, _mmToPts(216), _mmToPts(303));
            page.TrimBox = new Primitives.Rectangle(
                page.MediaBox.LLX + bleed,
                page.MediaBox.LLY + bleed,
                page.MediaBox.URX - bleed,
                page.MediaBox.URY - bleed
            );

            using (var eyeStream = File.OpenRead("Pexels_com/adult-blue-blue-eyes-865711.jpg"))
            {
                var scale = 3456d / 5184;

                var width = _mmToPts(100);
                var height = _mmToPts(100 * scale);

                var offSet = _mmToPts(6);
                page.AddImage(eyeStream, new Primitives.Rectangle(offSet, offSet, width + offSet, height + offSet));
            }
        });
}
Product 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 netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 was computed.  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 tizen30 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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-alpha018 44 11/21/2024
1.0.0-alpha017 42 11/20/2024
1.0.0-alpha016 44 11/19/2024
1.0.0-alpha015 115 9/19/2023
1.0.0-alpha014 144 1/26/2023
1.0.0-alpha013 144 1/19/2023
1.0.0-alpha012 109 1/18/2023
1.0.0-alpha011 2,436 8/24/2022
1.0.0-alpha010 802 2/25/2022
1.0.0-alpha009 739 3/6/2021
1.0.0-alpha008 300 12/5/2020
1.0.0-alpha007 431 7/10/2020
1.0.0-alpha006 292 7/8/2020
1.0.0-alpha005 449 4/22/2020
1.0.0-alpha004 399 3/17/2020
1.0.0-alpha003 394 3/11/2019
1.0.0-alpha002 911 3/6/2019
1.0.0-alpha001 389 3/6/2019