mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
make transform stack consistent
Some checks failed
Build, test and publish draft / build (push) Has been cancelled
Build and test [MacOS] / build (push) Has been cancelled
Run Common Crawl Tests / build (0000-0001) (push) Has been cancelled
Run Common Crawl Tests / build (0002-0003) (push) Has been cancelled
Run Common Crawl Tests / build (0004-0005) (push) Has been cancelled
Run Common Crawl Tests / build (0006-0007) (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
Nightly Release / Check if this commit has already been published (push) Has been cancelled
Nightly Release / tests (push) Has been cancelled
Nightly Release / build_and_publish_nightly (push) Has been cancelled
Some checks failed
Build, test and publish draft / build (push) Has been cancelled
Build and test [MacOS] / build (push) Has been cancelled
Run Common Crawl Tests / build (0000-0001) (push) Has been cancelled
Run Common Crawl Tests / build (0002-0003) (push) Has been cancelled
Run Common Crawl Tests / build (0004-0005) (push) Has been cancelled
Run Common Crawl Tests / build (0006-0007) (push) Has been cancelled
Run Integration Tests / build (push) Has been cancelled
Nightly Release / Check if this commit has already been published (push) Has been cancelled
Nightly Release / tests (push) Has been cancelled
Nightly Release / build_and_publish_nightly (push) Has been cancelled
This commit is contained in:
committed by
BobLd
parent
6ce6986d78
commit
181fa9d837
@@ -270,10 +270,10 @@
|
|||||||
GetCurrentState().FontState.WordSpacing = spacing;
|
GetCurrentState().FontState.WordSpacing = spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ModifyCurrentTransformationMatrix(double[] value)
|
public void ModifyCurrentTransformationMatrix(TransformationMatrix value)
|
||||||
{
|
{
|
||||||
var ctm = GetCurrentState().CurrentTransformationMatrix;
|
var state = GetCurrentState();
|
||||||
GetCurrentState().CurrentTransformationMatrix = TransformationMatrix.FromArray(value).Multiply(ctm);
|
state.CurrentTransformationMatrix = value.Multiply(state.CurrentTransformationMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCharacterSpacing(double spacing)
|
public void SetCharacterSpacing(double spacing)
|
||||||
|
|||||||
@@ -563,8 +563,8 @@
|
|||||||
.ToArray());
|
.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Update current transformation matrix.
|
// 2. Update current transformation matrix.
|
||||||
startState.CurrentTransformationMatrix = formMatrix.Multiply(startState.CurrentTransformationMatrix);
|
ModifyCurrentTransformationMatrix(formMatrix);
|
||||||
|
|
||||||
var contentStream = formStream.Decode(FilterProvider, PdfScanner);
|
var contentStream = formStream.Decode(FilterProvider, PdfScanner);
|
||||||
|
|
||||||
@@ -576,9 +576,8 @@
|
|||||||
if (formStream.StreamDictionary.TryGet<ArrayToken>(NameToken.Bbox, PdfScanner, out var bboxToken))
|
if (formStream.StreamDictionary.TryGet<ArrayToken>(NameToken.Bbox, PdfScanner, out var bboxToken))
|
||||||
{
|
{
|
||||||
var points = bboxToken.Data.OfType<NumericToken>().Select(x => x.Double).ToArray();
|
var points = bboxToken.Data.OfType<NumericToken>().Select(x => x.Double).ToArray();
|
||||||
PdfRectangle bbox = new PdfRectangle(points[0], points[1], points[2], points[3]);
|
PdfRectangle bbox = new PdfRectangle(points[0], points[1], points[2], points[3]).Normalise();
|
||||||
PdfRectangle transformedBox = startState.CurrentTransformationMatrix.Transform(bbox).Normalise();
|
ClipToRectangle(bbox, FillingRule.EvenOdd); // TODO - Check that Even Odd is valid
|
||||||
ClipToRectangle(transformedBox, FillingRule.EvenOdd); // TODO - Check that Even Odd is valid
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Paint the objects.
|
// 4. Paint the objects.
|
||||||
@@ -958,10 +957,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public virtual void ModifyCurrentTransformationMatrix(double[] value)
|
public virtual void ModifyCurrentTransformationMatrix(TransformationMatrix value)
|
||||||
{
|
{
|
||||||
var ctm = GetCurrentState().CurrentTransformationMatrix;
|
var state = GetCurrentState();
|
||||||
GetCurrentState().CurrentTransformationMatrix = TransformationMatrix.FromArray(value).Multiply(ctm);
|
state.CurrentTransformationMatrix = value.Multiply(state.CurrentTransformationMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -452,6 +452,7 @@ namespace UglyToad.PdfPig.Graphics
|
|||||||
{
|
{
|
||||||
// https://github.com/apache/pdfbox/blob/f4bfe47de37f6fe69e8f98b164c3546facfd5e91/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java#L611
|
// https://github.com/apache/pdfbox/blob/f4bfe47de37f6fe69e8f98b164c3546facfd5e91/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java#L611
|
||||||
var graphicsState = GetCurrentState();
|
var graphicsState = GetCurrentState();
|
||||||
|
rectangle = graphicsState.CurrentTransformationMatrix.Transform(rectangle).Normalise();
|
||||||
var clip = rectangle.ToPdfPath();
|
var clip = rectangle.ToPdfPath();
|
||||||
clip.SetClipping(clippingRule);
|
clip.SetClipping(clippingRule);
|
||||||
|
|
||||||
|
|||||||
@@ -243,7 +243,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modify the current transformation matrix by concatenating the specified matrix.
|
/// Modify the current transformation matrix by concatenating the specified matrix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void ModifyCurrentTransformationMatrix(double[] value);
|
void ModifyCurrentTransformationMatrix(TransformationMatrix value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the character spacing to a number expressed in unscaled text space units.
|
/// Set the character spacing to a number expressed in unscaled text space units.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using PdfPig.Core;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -43,7 +44,7 @@
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Run(IOperationContext operationContext)
|
public void Run(IOperationContext operationContext)
|
||||||
{
|
{
|
||||||
operationContext.ModifyCurrentTransformationMatrix(Value);
|
operationContext.ModifyCurrentTransformationMatrix(TransformationMatrix.FromArray(Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user