mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 02:44:58 +08:00
start passing the pdf scanner in to read the type 1 files
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
namespace UglyToad.PdfPig.Tokenization.Scanner
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@@ -9,7 +10,12 @@
|
||||
using Parser.Parts;
|
||||
using Tokens;
|
||||
|
||||
internal class PdfTokenScanner : ISeekableTokenScanner
|
||||
internal interface IPdfObjectScanner : ISeekableTokenScanner
|
||||
{
|
||||
ObjectToken Get(IndirectReference reference);
|
||||
}
|
||||
|
||||
internal class PdfTokenScanner : IPdfObjectScanner
|
||||
{
|
||||
private readonly IInputBytes inputBytes;
|
||||
private readonly IObjectLocationProvider objectLocationProvider;
|
||||
@@ -449,5 +455,22 @@
|
||||
{
|
||||
coreTokenScanner.DeregisterCustomTokenizer(tokenizer);
|
||||
}
|
||||
|
||||
public ObjectToken Get(IndirectReference reference)
|
||||
{
|
||||
if (!objectLocationProvider.TryGetOffset(reference, out var offset))
|
||||
{
|
||||
throw new InvalidOperationException($"Could not find the object with reference: {reference}.");
|
||||
}
|
||||
|
||||
Seek(offset);
|
||||
|
||||
if (!MoveNext())
|
||||
{
|
||||
throw new InvalidOperationException($"Could not parse the object with reference: {reference}.");
|
||||
}
|
||||
|
||||
return (ObjectToken)CurrentToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user