Skip to content

Commit afc4d35

Browse files
Generate order and shipment PDFs with PdfPig instead of Scryber (#982)
* Generate order and shipment PDFs with PdfPig instead of Scryber
1 parent a480641 commit afc4d35

26 files changed

Lines changed: 1543 additions & 1251 deletions

File tree

‎.ai/constraints.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Central package management is on (`ManagePackageVersionsCentrally=true`). An inl
1313
→ Add `<PackageVersion>` to `Directory.Packages.props`, reference without a version.
1414

1515
### Never add a package for a capability the repository already has
16-
`Grand.Mediator`, FluentValidation, `Grand.Mapping`, `MongoDB.Driver`, `StackExchange.Redis`, DotLiquid, Scryber, ImageSharp, MailKit, Scrutor are already present. Adding a second library for the same job splits the codebase.
16+
`Grand.Mediator`, FluentValidation, `Grand.Mapping`, `MongoDB.Driver`, `StackExchange.Redis`, DotLiquid, PdfPig, SkiaSharp, MailKit, Scrutor are already present. Adding a second library for the same job splits the codebase.
1717
→ See the table in `.ai/standards/dependencies.md`.
1818

1919
### Never use Newtonsoft.Json

‎.ai/knowledge/repository-map.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ Important folders:
114114
- `Controllers`
115115
- `Views`
116116
- `Views/Shared`
117-
- `Views/PdfTemplates`
118117
- `Components`
119118
- `Commands`
120119
- `Features`

‎.ai/knowledge/template-types.md‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,15 @@ Follow existing patterns:
100100
- Preserve Vue props, component names, and model shape.
101101
- Keep generated bundle requirements in sync with `src/Web/Grand.Web/vueapp`.
102102

103-
## PDF Templates
104-
Use for PDF views under:
105-
- `src/Web/Grand.Web/Views/PdfTemplates`
106-
107-
Follow existing PDF patterns:
108-
- Keep markup simple and deterministic.
109-
- Avoid interactive JavaScript.
110-
- Use inline or existing PDF-compatible styling.
103+
## PDF documents
104+
Order invoices and packaging slips are not views. `PdfService` in
105+
`src/Business/Grand.Business.Common/Services/Pdf` lays them out in code through `PdfComposer`
106+
(text, tables, images, page breaks) on top of PdfPig.
107+
108+
- Change the layout in `PdfService`; add a layout primitive to `PdfComposer` only when two documents need it.
109+
- HTML from the database (attribute descriptions, invoice header and footer) goes through `PdfHtmlText`, which drops markup.
110+
- Text is drawn with the embedded Noto Sans fonts; characters outside them print as `?`.
111+
- Plugins add lines below the payment method by handling `OrderPdfPaymentLinesEvent`; views and widget zones do not reach a PDF.
111112
- Preserve order, shipment, address, tax, and currency formatting.
112113

113114
## DotLiquid Message Templates

‎.ai/standards/dependencies.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Do not add a new third-party package when the repository already has a capabilit
2929
| MongoDB | `MongoDB.Driver` |
3030
| Caching / distributed cache | `Microsoft.Extensions.Caching.Memory`, `StackExchange.Redis` |
3131
| Templating for messages | `DotLiquid` |
32-
| PDF | `Scryber.Core` |
33-
| Images | `SixLabors.ImageSharp`, `SkiaSharp` |
32+
| PDF | `PdfPig` for writing PDF objects; layout in `Grand.Business.Common/Services/Pdf/PdfComposer` |
33+
| Images | `SkiaSharp` |
3434
| Mail | `MailKit` |
3535
| DI scanning | `Scrutor` |
3636
| API docs | `Microsoft.AspNetCore.OpenApi`, `Scalar.AspNetCore` |

‎.trivyignore‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
# on that date, so it has to be reviewed rather than forgotten.
33

44
# SixLabors.ImageSharp 3.1.12 (fixed in 4.1.2), a transitive dependency of
5-
# Scryber.Core, which pins 3.1.12 up to its latest release (9.7.5).
6-
# GrandNode does not reference ImageSharp; Scryber.Imaging only detects and
7-
# decodes images (TiffFormat, TiffMetadata, DecoderOptions). The affected code
8-
# is never called: the TIFF CCITT T4/T6 encoders and HistogramEqualization.
9-
# Drop these entries once Scryber.Core moves to ImageSharp 4.1.2 or later.
5+
# elFinder.Net.Core 1.5.0, lifted from 2.0.0 by Grand.Web.AdminShared.
6+
# GrandNode does not reference ImageSharp in code. 4.x is not verified with
7+
# elFinder. Drop these entries once ImageSharp moves to 4.1.2 or elFinder goes.
108
CVE-2026-106110 exp:2027-01-16
119
CVE-2026-106113 exp:2027-01-16
1210
CVE-2026-106115 exp:2027-01-16

‎Directory.Packages.props‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
<PackageVersion Include="Microsoft.FeatureManagement.AspNetCore" Version="4.8.0" />
1414
<PackageVersion Include="Microsoft.OpenApi" Version="2.12.2" />
1515
<PackageVersion Include="Scalar.AspNetCore" Version="2.17.13" />
16-
<PackageVersion Include="Scryber.Core" Version="9.7.4.4" />
17-
<PackageVersion Include="Scryber.Core.OpenType" Version="9.7.4" />
16+
<PackageVersion Include="PdfPig" Version="0.1.16" />
1817
<PackageVersion Include="MailKit" Version="4.18.1" />
1918
<PackageVersion Include="AWSSDK.Core" Version="4.0.102.8" />
2019
<PackageVersion Include="AWSSDK.S3" Version="4.0.104.1" />
@@ -51,6 +50,7 @@
5150
<PackageVersion Include="elFinder.Net.AspNetCore" Version="1.5.0" />
5251
<PackageVersion Include="elFinder.Net.Core" Version="1.5.0" />
5352
<PackageVersion Include="elFinder.Net.Drivers.FileSystem" Version="1.5.0" />
53+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.12" />
5454
<PackageVersion Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.5.4" />
5555
<PackageVersion Include="Azure.Extensions.AspNetCore.DataProtection.Keys" Version="1.6.4" />
5656
<PackageVersion Include="Azure.Identity" Version="1.21.0" />

‎src/Business/Grand.Business.Common/Grand.Business.Common.csproj‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
<ItemGroup>
44
<PackageReference Include="ExcelMapper" />
55
<PackageReference Include="Microsoft.Build.Tasks.Git" PrivateAssets="All" />
6-
<PackageReference Include="Scryber.Core" />
7-
<PackageReference Include="Scryber.Core.OpenType" />
8-
<PackageReference Include="System.Security.Cryptography.Xml" />
6+
<PackageReference Include="PdfPig" />
7+
<PackageReference Include="System.Security.Cryptography.Xml" />
8+
</ItemGroup>
9+
<ItemGroup>
10+
<EmbeddedResource Include="Services\Pdf\Fonts\*.ttf" LogicalName="Grand.Business.Common.Pdf.Fonts.%(Filename)%(Extension)" />
911
</ItemGroup>
1012
<ItemGroup>
1113
<ProjectReference Include="..\..\Core\Grand.Domain\Grand.Domain.csproj" />
Binary file not shown.
Binary file not shown.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
https://scripts.sil.org/OFL
6+
7+
8+
-----------------------------------------------------------
9+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10+
-----------------------------------------------------------
11+
12+
PREAMBLE
13+
The goals of the Open Font License (OFL) are to stimulate worldwide
14+
development of collaborative font projects, to support the font creation
15+
efforts of academic and linguistic communities, and to provide a free and
16+
open framework in which fonts may be shared and improved in partnership
17+
with others.
18+
19+
The OFL allows the licensed fonts to be used, studied, modified and
20+
redistributed freely as long as they are not sold by themselves. The
21+
fonts, including any derivative works, can be bundled, embedded,
22+
redistributed and/or sold with any software provided that any reserved
23+
names are not used by derivative works. The fonts and derivatives,
24+
however, cannot be released under any other type of license. The
25+
requirement for fonts to remain under this license does not apply
26+
to any document created using the fonts or their derivatives.
27+
28+
DEFINITIONS
29+
"Font Software" refers to the set of files released by the Copyright
30+
Holder(s) under this license and clearly marked as such. This may
31+
include source files, build scripts and documentation.
32+
33+
"Reserved Font Name" refers to any names specified as such after the
34+
copyright statement(s).
35+
36+
"Original Version" refers to the collection of Font Software components as
37+
distributed by the Copyright Holder(s).
38+
39+
"Modified Version" refers to any derivative made by adding to, deleting,
40+
or substituting -- in part or in whole -- any of the components of the
41+
Original Version, by changing formats or by porting the Font Software to a
42+
new environment.
43+
44+
"Author" refers to any designer, engineer, programmer, technical
45+
writer or other person who contributed to the Font Software.
46+
47+
PERMISSION & CONDITIONS
48+
Permission is hereby granted, free of charge, to any person obtaining
49+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
50+
redistribute, and sell modified and unmodified copies of the Font
51+
Software, subject to the following conditions:
52+
53+
1) Neither the Font Software nor any of its individual components,
54+
in Original or Modified Versions, may be sold by itself.
55+
56+
2) Original or Modified Versions of the Font Software may be bundled,
57+
redistributed and/or sold with any software, provided that each copy
58+
contains the above copyright notice and this license. These can be
59+
included either as stand-alone text files, human-readable headers or
60+
in the appropriate machine-readable metadata fields within text or
61+
binary files as long as those fields can be easily viewed by the user.
62+
63+
3) No Modified Version of the Font Software may use the Reserved Font
64+
Name(s) unless explicit written permission is granted by the corresponding
65+
Copyright Holder. This restriction only applies to the primary font name as
66+
presented to the users.
67+
68+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69+
Software shall not be used to promote, endorse or advertise any
70+
Modified Version, except to acknowledge the contribution(s) of the
71+
Copyright Holder(s) and the Author(s) or with their explicit written
72+
permission.
73+
74+
5) The Font Software, modified or unmodified, in part or in whole,
75+
must be distributed entirely under this license, and must not be
76+
distributed under any other license. The requirement for fonts to
77+
remain under this license does not apply to any document created
78+
using the Font Software.
79+
80+
TERMINATION
81+
This license becomes null and void if any of the above conditions are
82+
not met.
83+
84+
DISCLAIMER
85+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93+
OTHER DEALINGS IN THE FONT SOFTWARE.

0 commit comments

Comments
 (0)