ImageSharpCommunity.Formats.Pdf 0.2.0

dotnet add package ImageSharpCommunity.Formats.Pdf --version 0.2.0                
NuGet\Install-Package ImageSharpCommunity.Formats.Pdf -Version 0.2.0                
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="ImageSharpCommunity.Formats.Pdf" Version="0.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ImageSharpCommunity.Formats.Pdf --version 0.2.0                
#r "nuget: ImageSharpCommunity.Formats.Pdf, 0.2.0"                
#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 ImageSharpCommunity.Formats.Pdf as a Cake Addin
#addin nuget:?package=ImageSharpCommunity.Formats.Pdf&version=0.2.0

// Install ImageSharpCommunity.Formats.Pdf as a Cake Tool
#tool nuget:?package=ImageSharpCommunity.Formats.Pdf&version=0.2.0                

ImageSharpCommunity.Formats.Pdf

Downloads NuGet GitHub license

Image decoder for PDF files for ImageSharp based on PdfLibCore

Install

via NuGet:

PM> Install-Package ImageSharp.Community.Formats.Pdf

Usage

using System.IO;

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Processing;
using ImageSharpCommunity.Formats.Pdf;

// Create custom configuration with PDF decoder
var configuration = new Configuration(
    new PdfConfigurationModule());

using var inputStream = File.OpenRead("/path/to/document.pdf");
using var image = Image.Load(inputStream);

// Resize
image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2)); 

// Save image
image.SaveAsPng("document.png");

More info https://docs.sixlabors.com/articles/imagesharp/configuration.html

Usage in Umbraco

To use in Umbraco, you must inject the configuration in an appropriate manor, eg. in a Composer.

using Umbraco.Cms.Core.Composing;

namespace MyUmbracoProject;

public class PdfFormatComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
    {
        var config = SixLabors.ImageSharp.Configuration.Default.Clone();
        config.Configure(new ImageSharpCommunity.Formats.Pdf.PdfConfigurationModule());
    }
}

This will be picked up by Umbraco when starting the website, and adds the necessary configuration.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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
0.2.0 978 6/6/2024
0.1.0 118 5/23/2024