You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds three PDF rendering features to DemaConsulting.CanvasNet.Pdf:
AES-256 /R 6 encryption (ISO 32000-2 Algorithm 2.B hardened hash), with fixtures generated
independently via pypdf.
Text render modes 4-7 (text clipping).
Mesh shading types 4-7 (free-form and lattice triangle meshes, Coons and tensor-product
patches), via both the sh operator and /PatternType 2 shading patterns.
The last commit adds a hand-authored fixture, shading-mesh-types-4-5-6-7.pdf, with one quadrant per
mesh type, and an end-to-end system-integration test. The type 7 interior control points are crossed
so its interior visibly differs from type 6. The fixture was checked against Chrome's PDF viewer.
Type of Change
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to not work as expected)
Documentation update
Code quality improvement
Related Issues
Closes #
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
Code builds successfully and all tests pass: pwsh ./build.ps1 (11,844 tests, 0 failures)
Code produces zero warnings
Code Quality
New code has appropriate XML documentation comments
Static analyzer warnings have been addressed
Quality Checks
Please run the following checks before submitting:
All linters pass: pwsh ./lint.ps1 (no errors found)
Testing
Added unit tests for new functionality
Updated existing tests if behavior changed
All tests follow the AAA (Arrange, Act, Assert) pattern
Test coverage is maintained or improved
Documentation
Updated README.md (if applicable)
Updated docs/ documentation (if applicable)
Added code examples for new features (if applicable)
Updated requirements.yaml (if applicable)
Additional Notes
build.ps1 and lint.ps1 were run on the final commit. An automated code review of the fixture
commit found no issues; no formal review has been done.
…2.B)
Implement Algorithm 2.B for the standard security handler's validation hash
and intermediate key (user and owner variants), remove the R6 fail-closed
throw (unknown /R still throws pdf-encrypted-r-{n}), add pypdf-generated R6
fixtures and tests, and update requirements, design, verification, SysML2,
user guide, XML docs and fixtures README.
Add a hand-authored 400x400 PDF fixture painting one /ShadingType 4, 5, 6 and
7 mesh per quadrant via sh, with a system-integration test asserting corner
colors, unpainted regions, and that type 7 interior control points change the
interior relative to type 6.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR #44 review: rasterize meshes into a bitmap sized to the path's
device bounds instead of a full-page surface, and correct the design,
namespace and class docs on sh/W clipping, mesh types and Tr 4-7 limits.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
For a type-4 record starting with flag 0, this loop reads the flag fields of the next two vertices but never checks them. A reserved edge-flag value such as 3 in either field is therefore accepted, although the outer record path rejects values above 2 and the mesh fail-closed requirement says invalid flags must throw InvalidDataException. Validate these fields before adding their vertices, and cover a reserved flag in each position with a regression test.
Clip temporary mesh raster bounds before allocation
When sh has no /BBox, BuildShadingPaintRegion passes a full-page path. This method bounds the temporary surface only by that path; it applies _gs.Clip after rasterizing. Thus a mesh drawn under a tiny W n clip can still allocate an 8192×8192 temporary surface (roughly 256 MiB) and rasterize the whole page. Restrict the temporary raster bounds to the intersection of the paint region and the active clip before allocating and painting.
…ter to clip
Address PR #44 review: reject reserved edge flags on the 2nd/3rd vertex of a
flag-0 type 4 record, and intersect the temporary mesh raster with the active
clip's bounds (new internal ClipMask.Bounds) before allocating.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The path-bounds optimization does not help a sh mesh with no /BBox or active clip: BuildShadingPaintRegion(null) makes a full-page path, and PaintMesh allocates a temporary Surface of those bounds before rasterizing. A small mesh on an 8192×8192 page therefore still allocates about 256 MiB per paint, even though most pixels remain transparent. Bound the temporary to the transformed mesh geometry as well as the path and clip (preserving the pattern /Background area), or avoid the full-page temporary for this case.
For a mesh with /Function, each vertex or patch-corner parameter must be mapped to a color before those colors are interpolated. Here the interpolated parameter is looked up instead: with endpoint parameters 0 and 1 and a nonlinear function f(t)=t², a midpoint becomes f(0.5)=0.25 rather than the midpoint of endpoint colors, 0.5. Map samples through the function when decoding their colors, then interpolate the resulting components; cover this with a nonlinear-function mesh test.
Add mesh shading tests to review paths
.reviewmark.yaml:764
This review's paths include the new mesh source, but not test/DemaConsulting.CanvasNet.Pdf.Tests/PdfDocumentMeshShadingTests.cs. Add the new 894-line test file alongside the other PdfDocument tests so ReviewMark's unit review includes the verification code.
This section now describes mesh shadings as supported, but the error-handling list at line 1529 still says every /ShadingType other than 2 or 3 is unsupported. Change that list to say types outside 2–7 so the design document does not contradict the new behavior.
The owner-password requirement still limits the Algorithm 2.A path to R5 (line 309), even though this change adds an R6 owner-password test here and implements its Algorithm 2.B hash. Extend the requirement text to cover R5 and R6, distinguishing the R6 hash.
The updated sourceRef includes the mesh implementation, but the testRef immediately below omits test/DemaConsulting.CanvasNet.Pdf.Tests/PdfDocumentMeshShadingTests.cs. Add the new test file to testRef so the modeled unit's verification artifacts remain discoverable, as required by the repository's SysML artifact-location convention.
Thanks - I looked into the mesh /Function finding (Mesh.cs:848) and believe the current behavior is the spec-correct one. For mesh shadings (ISO 32000-1 8.7.4.5.5-8.7.4.5.8), when /Function is present the per-vertex (or per-patch-corner) value is a single parametric value t. The spec has t interpolated across the triangle/patch and the function applied to the interpolated t to obtain the color; the function is not applied at the vertices before interpolation. With f(t)=t^2 and endpoints 0 and 1 the midpoint evaluates to f(0.5)=0.25, which is the intended result; pre-mapping the vertices would make any nonlinear function (for example multi-stop ramps) collapse to a straight endpoint blend. So the order of operations is unchanged. Two valid sub-points will be addressed in a follow-up: the function is sampled through a 256-entry lookup table (adding interpolation between entries) and a nonlinear-function mesh test will be added to pin this behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds three PDF rendering features to
DemaConsulting.CanvasNet.Pdf:/R 6encryption (ISO 32000-2 Algorithm 2.B hardened hash), with fixtures generatedindependently via
pypdf.patches), via both the
shoperator and/PatternType 2shading patterns.The last commit adds a hand-authored fixture,
shading-mesh-types-4-5-6-7.pdf, with one quadrant permesh type, and an end-to-end system-integration test. The type 7 interior control points are crossed
so its interior visibly differs from type 6. The fixture was checked against Chrome's PDF viewer.
Type of Change
Related Issues
Closes #
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
pwsh ./build.ps1(11,844 tests, 0 failures)Code Quality
Quality Checks
Please run the following checks before submitting:
pwsh ./lint.ps1(no errors found)Testing
Documentation
Additional Notes
build.ps1andlint.ps1were run on the final commit. An automated code review of the fixturecommit found no issues; no formal review has been done.