PdfPig/src/UglyToad.PdfPig/Content/HeaderVersion.cs
Eliot Jones 693a3d5958 use offset to file header to correct cross references
if the %pdf version header comment is offset from the start of the file the cross reference offsets will also be wrong by that amount. this change updates the cross reference location logic to use the offset from the located version header.
2020-01-26 15:30:20 +00:00

33 lines
904 B
C#

namespace UglyToad.PdfPig.Content
{
using System;
internal class HeaderVersion
{
public decimal Version { get; }
public string VersionString { get; }
/// <summary>
/// The offset in bytes from the start of the file to the start of the version comment.
/// </summary>
public long OffsetInFile { get; }
public HeaderVersion(decimal version, string versionString, long offsetInFile)
{
Version = version;
VersionString = versionString;
if (offsetInFile < 0)
{
throw new ArgumentOutOfRangeException($"Invalid offset for header version, must be positive. Got: {offsetInFile}.");
}
OffsetInFile = offsetInFile;
}
public override string ToString()
{
return $"Version: {VersionString}";
}
}
}