Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more classes to the Public API #717

Merged
merged 6 commits into from
Oct 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/UglyToad.PdfPig.Tests/PublicApiScannerTests.cs
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@ public void OnlyExposedApiIsPublic()
"UglyToad.PdfPig.Content.Page",
"UglyToad.PdfPig.Content.PageRotationDegrees",
"UglyToad.PdfPig.Content.PageSize",
"UglyToad.PdfPig.Content.PageTreeMembers",
"UglyToad.PdfPig.Content.PageTreeNode",
"UglyToad.PdfPig.Content.Word",
"UglyToad.PdfPig.Content.TextOrientation",
@@ -99,6 +100,7 @@ public void OnlyExposedApiIsPublic()
"UglyToad.PdfPig.Filters.DefaultFilterProvider",
"UglyToad.PdfPig.Filters.IFilter",
"UglyToad.PdfPig.Filters.IFilterProvider",
"UglyToad.PdfPig.Filters.ILookupFilterProvider",
"UglyToad.PdfPig.Functions.FunctionTypes",
"UglyToad.PdfPig.Functions.PdfFunction",
"UglyToad.PdfPig.PdfFonts.CharacterBoundingBox",
@@ -109,9 +111,11 @@ public void OnlyExposedApiIsPublic()
"UglyToad.PdfPig.PdfFonts.FontStretch",
"UglyToad.PdfPig.PdfFonts.IFont",
"UglyToad.PdfPig.Geometry.GeometryExtensions",
"UglyToad.PdfPig.Geometry.UserSpaceUnit",
"UglyToad.PdfPig.Graphics.Colors.CMYKColor",
"UglyToad.PdfPig.Graphics.Colors.ColorSpace",
"UglyToad.PdfPig.Graphics.PdfPath",
"UglyToad.PdfPig.Graphics.Colors.ResourceColorSpace",
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceExtensions",
"UglyToad.PdfPig.Graphics.Colors.ColorSpaceFamily",
"UglyToad.PdfPig.Graphics.Colors.GrayColor",
@@ -152,6 +156,7 @@ public void OnlyExposedApiIsPublic()
"UglyToad.PdfPig.Graphics.CurrentFontState",
"UglyToad.PdfPig.Graphics.CurrentGraphicsState",
"UglyToad.PdfPig.Graphics.IColorSpaceContext",
"UglyToad.PdfPig.Graphics.InlineImageBuilder",
"UglyToad.PdfPig.Graphics.IOperationContext",
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByEvenOddIntersect",
"UglyToad.PdfPig.Graphics.Operations.ClippingPaths.ModifyClippingByNonZeroWindingIntersect",
@@ -227,6 +232,7 @@ public void OnlyExposedApiIsPublic()
"UglyToad.PdfPig.Graphics.Operations.TextState.SetWordSpacing",
"UglyToad.PdfPig.Graphics.Operations.TextState.Type3SetGlyphWidth",
"UglyToad.PdfPig.Graphics.Operations.TextState.Type3SetGlyphWidthAndBoundingBox",
"UglyToad.PdfPig.Graphics.PerformantRectangleTransformer",
"UglyToad.PdfPig.Graphics.TextMatrices",
"UglyToad.PdfPig.Graphics.XObjectContentRecord",
"UglyToad.PdfPig.Images.ColorSpaceDetailsByteConverter",
@@ -240,12 +246,15 @@ public void OnlyExposedApiIsPublic()
"UglyToad.PdfPig.Outline.Destinations.ExplicitDestination",
"UglyToad.PdfPig.Outline.Destinations.ExplicitDestinationCoordinates",
"UglyToad.PdfPig.Outline.Destinations.ExplicitDestinationType",
"UglyToad.PdfPig.Outline.Destinations.NamedDestinations",
"UglyToad.PdfPig.ParsingOptions",
"UglyToad.PdfPig.Parser.IPageContentParser",
"UglyToad.PdfPig.PdfDocument",
"UglyToad.PdfPig.PdfExtensions",
"UglyToad.PdfPig.Rendering.IPageImageRenderer",
"UglyToad.PdfPig.Rendering.PdfRendererImageFormat",
"UglyToad.PdfPig.Structure",
"UglyToad.PdfPig.Tokenization.Scanner.IPdfTokenScanner",
"UglyToad.PdfPig.Util.Adler32Checksum",
"UglyToad.PdfPig.Util.IWordExtractor",
"UglyToad.PdfPig.Util.DefaultWordExtractor",
6 changes: 3 additions & 3 deletions src/UglyToad.PdfPig/Content/Catalog.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
namespace UglyToad.PdfPig.Content
{
{
using System;
using Outline;
using Outline.Destinations;
using Tokens;
using Util.JetBrains.Annotations;

/// <summary>
/// The root of the document's object hierarchy. Contains references to objects defining the contents,
/// outline, named destinations and more.
/// </summary>
public class Catalog
public sealed class Catalog
{
/// <summary>
/// The catalog dictionary containing assorted information.
2 changes: 1 addition & 1 deletion src/UglyToad.PdfPig/Content/IPageFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace UglyToad.PdfPig.Content
{
using Outline;
using Outline.Destinations;
using Tokens;

internal interface IPageFactory
17 changes: 13 additions & 4 deletions src/UglyToad.PdfPig/Content/PageTreeMembers.cs
Original file line number Diff line number Diff line change
@@ -6,17 +6,26 @@
/// <summary>
/// Contains the values inherited from the Page Tree for this page.
/// </summary>
internal class PageTreeMembers
public sealed class PageTreeMembers
{
public CropBox GetCropBox()
internal CropBox GetCropBox()
{
return null;
}

public MediaBox MediaBox { get; set; }
/// <summary>
/// The page media box.
/// </summary>
public MediaBox MediaBox { get; internal set; }

public int Rotation { get; set; }
/// <summary>
/// The page rotation.
/// </summary>
public int Rotation { get; internal set; }

/// <summary>
/// The page parent resources.
/// </summary>
public Queue<DictionaryToken> ParentResources { get; } = new Queue<DictionaryToken>();
}
}
2 changes: 1 addition & 1 deletion src/UglyToad.PdfPig/Content/Pages.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace UglyToad.PdfPig.Content
{
using Core;
using Outline;
using Outline.Destinations;
using System;
using System.Collections.Generic;
using Tokenization.Scanner;
8 changes: 7 additions & 1 deletion src/UglyToad.PdfPig/Filters/IFilterProvider.cs
Original file line number Diff line number Diff line change
@@ -25,8 +25,14 @@ public interface IFilterProvider
IReadOnlyList<IFilter> GetAllFilters();
}

internal interface ILookupFilterProvider : IFilterProvider
/// <summary>
/// Gets filter implementations (<see cref="IFilter"/>) for decoding PDF data.
/// </summary>
public interface ILookupFilterProvider : IFilterProvider
{
/// <summary>
/// Get the filters specified in this dictionary, using the <see cref="IPdfTokenScanner"/>.
/// </summary>
IReadOnlyList<IFilter> GetFilters(DictionaryToken dictionary, IPdfTokenScanner scanner);
}
}
8 changes: 6 additions & 2 deletions src/UglyToad.PdfPig/Geometry/UserSpaceUnit.cs
Original file line number Diff line number Diff line change
@@ -7,8 +7,11 @@
/// By default user space units correspond to 1/72nd of an inch (a typographic point).
/// The UserUnit entry in a page dictionary can define the space units as a different multiple of 1/72 (1 point).
/// </summary>
internal readonly struct UserSpaceUnit
public readonly struct UserSpaceUnit
{
/// <summary>
/// Default user space units with <see cref="PointMultiples"/> set to <c>1</c>.
/// </summary>
public static readonly UserSpaceUnit Default = new UserSpaceUnit(1);

/// <summary>
@@ -19,7 +22,7 @@ internal readonly struct UserSpaceUnit
/// <summary>
/// Create a new unit specification for a page.
/// </summary>
public UserSpaceUnit(int pointMultiples)
internal UserSpaceUnit(int pointMultiples)
{
if (pointMultiples <= 0)
{
@@ -29,6 +32,7 @@ public UserSpaceUnit(int pointMultiples)
PointMultiples = pointMultiples;
}

/// <inheritdoc/>
public override string ToString()
{
return PointMultiples.ToString(CultureInfo.InvariantCulture);
12 changes: 9 additions & 3 deletions src/UglyToad.PdfPig/Graphics/Colors/ResourceColorSpace.cs
Original file line number Diff line number Diff line change
@@ -5,18 +5,24 @@
/// <summary>
/// A color space definition from a resource dictionary.
/// </summary>
internal readonly struct ResourceColorSpace
public readonly struct ResourceColorSpace
{
/// <summary>
/// The color space name.
/// </summary>
public NameToken Name { get; }

/// <summary>
/// The color space data.
/// </summary>
public IToken Data { get; }

public ResourceColorSpace(NameToken name, IToken data)
internal ResourceColorSpace(NameToken name, IToken data)
{
Name = name;
Data = data;
}

public ResourceColorSpace(NameToken name) : this(name, null) { }
internal ResourceColorSpace(NameToken name) : this(name, null) { }
}
}
19 changes: 13 additions & 6 deletions src/UglyToad.PdfPig/Graphics/InlineImageBuilder.cs
Original file line number Diff line number Diff line change
@@ -3,22 +3,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Colors;
using Content;
using Core;
using Filters;
using PdfPig.Core;
using Tokenization.Scanner;
using Tokens;
using Util;

internal class InlineImageBuilder
/// <summary>
/// Inline Image Builder.
/// </summary>
public sealed class InlineImageBuilder
{
public IReadOnlyDictionary<NameToken, IToken> Properties { get; set; }
/// <summary>
/// Inline image properties.
/// </summary>
public IReadOnlyDictionary<NameToken, IToken> Properties { get; internal set; }

public IReadOnlyList<byte> Bytes { get; set; }
/// <summary>
/// Inline image bytes.
/// </summary>
public IReadOnlyList<byte> Bytes { get; internal set; }

public InlineImage CreateInlineImage(TransformationMatrix transformationMatrix, ILookupFilterProvider filterProvider,
internal InlineImage CreateInlineImage(TransformationMatrix transformationMatrix, ILookupFilterProvider filterProvider,
IPdfTokenScanner tokenScanner,
RenderingIntent defaultRenderingIntent,
IResourceStore resourceStore)
Original file line number Diff line number Diff line change
@@ -2,8 +2,14 @@
{
using PdfPig.Core;

internal static class PerformantRectangleTransformer
/// <summary>
/// Performant rectangle transformer.
/// </summary>
public static class PerformantRectangleTransformer
{
/// <summary>
/// Transform the rectangle using the matrices.
/// </summary>
public static PdfRectangle Transform(TransformationMatrix first, TransformationMatrix second, TransformationMatrix third, PdfRectangle rectangle)
{
var tl = rectangle.TopLeft;
7 changes: 3 additions & 4 deletions src/UglyToad.PdfPig/Outline/Destinations/NamedDestinations.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
namespace UglyToad.PdfPig.Outline
namespace UglyToad.PdfPig.Outline.Destinations
{
using System.Collections.Generic;
using Content;
using Destinations;
using Logging;
using System.Collections.Generic;
using Tokens;

/// <summary>
/// Named destinations in a PDF document
/// </summary>
internal class NamedDestinations
public class NamedDestinations
{
/// <summary>
/// Dictionary containing explicit destinations, keyed by name
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
namespace UglyToad.PdfPig.Outline
namespace UglyToad.PdfPig.Outline.Destinations
{
using System.Collections.Generic;
using Content;
using Destinations;
using Logging;
using Parser.Parts;
using System.Collections.Generic;
using System.Diagnostics;
using Tokenization.Scanner;
using Tokens;

2 changes: 1 addition & 1 deletion src/UglyToad.PdfPig/Parser/CatalogFactory.cs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
using Content;
using Core;
using Logging;
using Outline;
using Outline.Destinations;
using Parts;
using Tokenization.Scanner;
using Tokens;
8 changes: 7 additions & 1 deletion src/UglyToad.PdfPig/Parser/IPageContentParser.cs
Original file line number Diff line number Diff line change
@@ -5,8 +5,14 @@
using Graphics.Operations;
using Logging;

internal interface IPageContentParser
/// <summary>
/// Page content parser interface.
/// </summary>
public interface IPageContentParser
{
/// <summary>
/// Parse the <see cref="IInputBytes"/> into <see cref="IGraphicsStateOperation"/>s.
/// </summary>
IReadOnlyList<IGraphicsStateOperation> Parse(int pageNumber, IInputBytes inputBytes,
ILog log);
}
1 change: 1 addition & 0 deletions src/UglyToad.PdfPig/Parser/PageFactory.cs
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
using Graphics.Operations;
using Logging;
using Outline;
using Outline.Destinations;
using Parts;
using Tokenization.Scanner;
using Tokens;
1 change: 1 addition & 0 deletions src/UglyToad.PdfPig/PdfDocument.cs
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
using Tokenization.Scanner;
using Tokens;
using Outline;
using Outline.Destinations;
using Util.JetBrains.Annotations;

/// <inheritdoc />
16 changes: 11 additions & 5 deletions src/UglyToad.PdfPig/PdfExtensions.cs
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ public static class PdfExtensions
/// <summary>
/// Try and get the entry with a given name and type or look-up the object if it's an indirect reference.
/// </summary>
internal static bool TryGet<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner tokenScanner, out T token) where T : IToken
public static bool TryGet<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner tokenScanner, out T token) where T : IToken
{
token = default(T);
if (!dictionary.TryGet(name, out var t) || !(t is T typedToken))
@@ -31,8 +31,11 @@ internal static bool TryGet<T>(this DictionaryToken dictionary, NameToken name,
token = typedToken;
return true;
}

internal static T Get<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner scanner) where T : class, IToken

/// <summary>
/// Get the entry with a given name and type or look-up the object if it's an indirect reference.
/// </summary>
public static T Get<T>(this DictionaryToken dictionary, NameToken name, IPdfTokenScanner scanner) where T : class, IToken
{
if (!dictionary.TryGet(name, out var token) || !(token is T typedToken))
{
@@ -61,9 +64,12 @@ public static IReadOnlyList<byte> Decode(this StreamToken stream, IFilterProvide
}

return transform;
}
}

internal static IReadOnlyList<byte> Decode(this StreamToken stream, ILookupFilterProvider filterProvider, IPdfTokenScanner scanner)
/// <summary>
/// Get the decoded data from this stream.
/// </summary>
public static IReadOnlyList<byte> Decode(this StreamToken stream, ILookupFilterProvider filterProvider, IPdfTokenScanner scanner)
{
var filters = filterProvider.GetFilters(stream.StreamDictionary, scanner);

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
/// <summary>
/// Tokenizes objects from bytes in a PDF file.
/// </summary>
internal interface IPdfTokenScanner : ISeekableTokenScanner, IDisposable
public interface IPdfTokenScanner : ISeekableTokenScanner, IDisposable
{
/// <summary>
/// Tokenize the object with a given object number.