PdfPig/src/UglyToad.PdfPig/Structure.cs
romain v 5a82c36631 FIX : undefined references is a valid use case.
I tried to mitigate the breaking change by keep on throwing in most uses of the change method.
2020-08-17 11:10:44 +02:00

52 lines
1.9 KiB
C#

namespace UglyToad.PdfPig
{
using System;
using Content;
using Core;
using CrossReference;
using Tokenization.Scanner;
using Tokens;
using Util.JetBrains.Annotations;
/// <summary>
/// Provides access to explore and retrieve the underlying PDF objects from the document.
/// </summary>
public class Structure
{
/// <summary>
/// The root of the document's hierarchy providing access to the page tree as well as other information.
/// </summary>
[NotNull]
public Catalog Catalog { get; }
/// <summary>
/// The cross-reference table enables direct access to objects by number.
/// </summary>
[NotNull]
public CrossReferenceTable CrossReferenceTable { get; }
/// <summary>
/// Provides access to tokenization capabilities for objects by object number.
/// </summary>
internal IPdfTokenScanner TokenScanner { get; }
internal Structure(Catalog catalog, CrossReferenceTable crossReferenceTable,
IPdfTokenScanner scanner)
{
Catalog = catalog ?? throw new ArgumentNullException(nameof(catalog));
CrossReferenceTable = crossReferenceTable ?? throw new ArgumentNullException(nameof(crossReferenceTable));
TokenScanner = scanner ?? throw new ArgumentNullException(nameof(scanner));
}
/// <summary>
/// Retrieve the tokenized object with the specified object reference number.
/// </summary>
/// <param name="reference">The object reference number.</param>
/// <returns>The tokenized PDF object from the file.</returns>
public ObjectToken GetObject(IndirectReference reference)
{
return TokenScanner.Get(reference) ?? throw new InvalidOperationException($"Could not find the object with reference: {reference}.");
}
}
}