PdfForge 1.1.1

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

// Install PdfForge as a Cake Tool
#tool nuget:?package=PdfForge&version=1.1.1                

PdfForge

NuGet

PdfForge is a library for rendering PDF documents into PNG images. It supports both saving pages to files and converting pages into byte arrays, making it a flexible solution for applications that need to work with PDF files in raster format.

Features

  • Open PDF documents from a file.
  • Render PDF pages to PNG images.
  • Save pages as PNG files.
  • Get pages as byte arrays (PNG format).
  • Supports scaling when rendering pages.

Installation

Install via NuGet by adding a reference to the PdfForge package:

dotnet add package PdfForge

Usage

Opening Document

To work with a PDF document, create an instance of the PdfForgeDocument class and provide the file path:

using PdfForge;

var pdfDocument = new PdfForgeDocument("sample.pdf");
Console.WriteLine($"Total Pages: {pdfDocument.TotalPages}");

Saving a Page as a PNG File

You can save a specific PDF page as a PNG file by specifying the page number and output file path:

pdfDocument.SavePageToPngFile(1, "page1.png");

Getting a Page as a Byte Array

You can also retrieve a PDF page as a byte array (in PNG format), useful for handling images in memory:

byte[] pageBytes = pdfDocument.GetPageBytes(1);

Releasing Resources

It's important to release resources when the document is no longer needed. You can call Dispose manually or use using to automatically release resources:

pdfDocument.Dispose();

Or with using:

using var pdfDocument = new PdfForgeDocument("sample.pdf");

Requirements

  • .NET 8.0 or later.

License

This project is licensed under the Apache v2.0 license.

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.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PdfForge:

Package Downloads
PdfForge.Avalonia

This library provides a custom control for Avalonia UI to render and display PDF documents using the PdfForge library. It supports rendering PDF pages as images and allows scaling for flexible display. PdfForge.Avalonia is ideal for Avalonia-based applications that require direct PDF visualization or manipulation through PdfForge, offering efficient rasterization into memory or files.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.4 125 10/24/2024
1.1.3 105 10/24/2024
1.1.2 144 10/24/2024
1.1.1 124 10/24/2024
1.0.0 96 10/21/2024 1.0.0 is deprecated because it is no longer maintained and has critical bugs.