2018-01-10 19:49:32 +00:00
|
|
|
|
namespace UglyToad.PdfPig.Graphics
|
2017-12-02 14:11:20 +00:00
|
|
|
|
{
|
2020-01-08 10:34:01 +00:00
|
|
|
|
using PdfPig.Core;
|
2017-12-31 14:11:13 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-11-16 20:00:12 +00:00
|
|
|
|
using Tokens;
|
2018-12-12 00:09:15 +00:00
|
|
|
|
using Util.JetBrains.Annotations;
|
2017-12-02 14:11:20 +00:00
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The current graphics state context when running a PDF content stream.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IOperationContext
|
2017-12-02 14:11:20 +00:00
|
|
|
|
{
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The current path being drawn if applicable.
|
|
|
|
|
/// </summary>
|
2018-12-12 00:09:15 +00:00
|
|
|
|
[CanBeNull]
|
|
|
|
|
PdfPath CurrentPath { get; }
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
2019-07-10 21:31:23 +01:00
|
|
|
|
/// The active colorspaces for this content stream.
|
|
|
|
|
/// </summary>
|
2019-08-04 16:47:47 +01:00
|
|
|
|
IColorSpaceContext ColorSpaceContext { get; }
|
2019-07-10 21:31:23 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The current position.
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// </summary>
|
2018-12-12 00:09:15 +00:00
|
|
|
|
PdfPoint CurrentPosition { get; set; }
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the currently active <see cref="CurrentGraphicsState"/>. States are stored on a stack structure.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The currently active graphics state.</returns>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
CurrentGraphicsState GetCurrentState();
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The matrices for the current text state.
|
|
|
|
|
/// </summary>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
TextMatrices TextMatrices { get; }
|
|
|
|
|
|
2019-07-24 00:00:00 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The current transformation matrix
|
|
|
|
|
/// </summary>
|
|
|
|
|
TransformationMatrix CurrentTransformationMatrix { get; }
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of graphics states on the stack.
|
|
|
|
|
/// </summary>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
int StackSize { get; }
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the current graphics state to the state from the top of the stack.
|
|
|
|
|
/// </summary>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
void PopState();
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Saves a copy of the current graphics state on the stack.
|
|
|
|
|
/// </summary>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
void PushState();
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Shows the text represented by the provided bytes using the current graphics state.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bytes">The bytes of the text.</param>
|
2017-12-02 14:11:20 +00:00
|
|
|
|
void ShowText(IInputBytes bytes);
|
2017-12-31 14:11:13 +00:00
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interprets the tokens to draw text at positions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tokens">The tokens to show.</param>
|
2017-12-31 14:11:13 +00:00
|
|
|
|
void ShowPositionedText(IReadOnlyList<IToken> tokens);
|
2018-04-26 22:22:29 +01:00
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Retrieves the named XObject and applies it to the current state.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="xObjectName">The name of the XObject.</param>
|
|
|
|
|
void ApplyXObject(NameToken xObjectName);
|
2018-12-12 00:09:15 +00:00
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Start a new sub-path.
|
|
|
|
|
/// </summary>
|
2018-12-12 00:09:15 +00:00
|
|
|
|
void BeginSubpath();
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Stroke the current path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="close">Whether to also close the path.</param>
|
2018-12-12 00:09:15 +00:00
|
|
|
|
void StrokePath(bool close);
|
|
|
|
|
|
2019-07-16 00:35:29 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fill the current path.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="close">Whether to also close the path.</param>
|
|
|
|
|
void FillPath(bool close);
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Close the current path.
|
|
|
|
|
/// </summary>
|
2018-12-12 00:09:15 +00:00
|
|
|
|
void ClosePath();
|
2019-07-06 14:03:23 +01:00
|
|
|
|
|
2020-01-08 10:34:01 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
void BeginMarkedContent(NameToken name, NameToken propertyDictionaryName, DictionaryToken Properties);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
void EndMarkedContent();
|
|
|
|
|
|
2019-07-06 14:03:23 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Update the graphics state to apply the state from the named ExtGState dictionary.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stateName">The name of the state to apply.</param>
|
|
|
|
|
void SetNamedGraphicsState(NameToken stateName);
|
2019-10-08 14:04:36 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicate that an inline image is being defined.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void BeginInlineImage();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Define the properties of the inline image currently being drawn.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void SetInlineImageProperties(IReadOnlyDictionary<NameToken, IToken> properties);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates that the current inline image is complete.
|
|
|
|
|
/// </summary>
|
|
|
|
|
void EndInlineImage(IReadOnlyList<byte> bytes);
|
2017-12-02 14:11:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|