.NETFramework4.6.2.NETFramework4.7.1net6.0net8.0.NETStandard2.0
PdfPig implementation of the DCT (Jpeg) filter, based on JpegLibrary.
Published
May 30, 2025
1y ago
Total Downloads
349.5K
349,473
Install
dotnet add package PdfPig.Filters.Dct.JpegLibrary --version 0.1.11-alpha001
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard | |
| Other |
README
UglyToad.PdfPig.Filters.Dct.JpegLibrary
PdfPig implementation of the DCT (Jpeg) filter, based on JpegLibrary (MIT License - See LICENCE and THIRD-PARTY-NOTICES)
Other filters
- JPX filter available here: https://github.com/BobLd/UglyToad.PdfPig.Filters.Jpx.OpenJpegDotNet
- JBIG2 filter available here: https://github.com/BobLd/UglyToad.PdfPig.Filters.Jbig2.PdfboxJbig2
Usage
// Create your filter provider
public sealed class MyFilterProvider : BaseFilterProvider
{
/// <summary>
/// The single instance of this provider.
/// </summary>
public static readonly IFilterProvider Instance = new MyFilterProvider();
/// <inheritdoc/>
private MyFilterProvider() : base(GetDictionary())
{
}
private static Dictionary<string, IFilter> GetDictionary()
{
var ascii85 = new Ascii85Filter();
var asciiHex = new AsciiHexDecodeFilter();
var ccitt = new CcittFaxDecodeFilter();
var dct = new JpegLibraryDctDecodeFilter(); // new filter
var flate = new FlateFilter();
var jbig2 = new Jbig2DecodeFilter();
var jpx = new JpxDecodeFilter();
var runLength = new RunLengthFilter();
var lzw = new LzwFilter();
return new Dictionary<string, IFilter>
{
{ NameToken.Ascii85Decode.Data, ascii85 },
{ NameToken.Ascii85DecodeAbbreviation.Data, ascii85 },
{ NameToken.AsciiHexDecode.Data, asciiHex },
{ NameToken.AsciiHexDecodeAbbreviation.Data, asciiHex },
{ NameToken.CcittfaxDecode.Data, ccitt },
{ NameToken.CcittfaxDecodeAbbreviation.Data, ccitt },
{ NameToken.DctDecode.Data, dct }, // new filter
{ NameToken.DctDecodeAbbreviation.Data, dct }, // new filter
{ NameToken.FlateDecode.Data, flate },
{ NameToken.FlateDecodeAbbreviation.Data, flate },
{ NameToken.Jbig2Decode.Data, jbig2 },
{ NameToken.JpxDecode.Data, jpx },
{ NameToken.RunLengthDecode.Data, runLength },
{ NameToken.RunLengthDecodeAbbreviation.Data, runLength },
{ NameToken.LzwDecode.Data, lzw },
{ NameToken.LzwDecodeAbbreviation.Data, lzw }
};
}
}
var parsingOption = new ParsingOptions()
{
UseLenientParsing = true,
SkipMissingFonts = true,
FilterProvider = MyFilterProvider.Instance
};
using (var doc = PdfDocument.Open("test.pdf", parsingOption))
{
int i = 0;
foreach (var page in doc.GetPages())
{
foreach (var pdfImage in page.GetImages())
{
Assert.True(pdfImage.TryGetPng(out var bytes));
File.WriteAllBytes($"image_{i++}.png", bytes);
}
}
}
Changes from Previous Version
No structural changes between v0.1.10.2 and v0.1.11-alpha001.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 5 target frameworks; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.