mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
support both xobject and inline images. adds unsupported filters so that exceptions are only thrown when accessing lazily evaluated image.bytes property rather than when opening the page. treat all warnings as errors.
54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
namespace UglyToad.PdfPig.Graphics.Operations.InlineImages
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
/// <inheritdoc />
|
|
/// <summary>
|
|
/// End an inline image object.
|
|
/// </summary>
|
|
public class EndInlineImage : IGraphicsStateOperation
|
|
{
|
|
/// <summary>
|
|
/// The symbol for this operation in a stream.
|
|
/// </summary>
|
|
public const string Symbol = "EI";
|
|
|
|
/// <summary>
|
|
/// The raw data for the inline image which should be interpreted according to the corresponding <see cref="BeginInlineImageData.Dictionary"/>.
|
|
/// </summary>
|
|
public IReadOnlyList<byte> ImageData { get; }
|
|
|
|
/// <inheritdoc />
|
|
public string Operator => Symbol;
|
|
|
|
/// <summary>
|
|
/// Create a new <see cref="EndInlineImage"/> operation.
|
|
/// </summary>
|
|
/// <param name="imageData">The raw byte data of this image.</param>
|
|
public EndInlineImage(IReadOnlyList<byte> imageData)
|
|
{
|
|
ImageData = imageData ?? throw new ArgumentNullException(nameof(imageData));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Run(IOperationContext operationContext)
|
|
{
|
|
operationContext.EndInlineImage(ImageData);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void Write(Stream stream)
|
|
{
|
|
stream.WriteText(Symbol);
|
|
stream.WriteNewLine();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
{
|
|
return Symbol;
|
|
}
|
|
}
|
|
} |