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
Copy file name to clipboardExpand all lines: net/developer-guide/advanced-usage/conversion-events.md
+105-2Lines changed: 105 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: Conversion events
5
5
linkTitle: Conversion events
6
6
weight: 4
7
7
description: "Subscribe to pipeline lifecycle and per-result conversion events through the typed ConversionEvents aggregator in GroupDocs.Conversion for .NET."
@@ -21,7 +21,7 @@ The aggregator is registered with the [Converter](https://reference.groupdocs.co
21
21
22
22
## Event groups
23
23
24
-
`ConversionEvents` exposes two distinct groups of handlers.
24
+
`ConversionEvents` exposes three distinct groups of handlers.
25
25
26
26
### Pipeline lifecycle
27
27
@@ -51,6 +51,16 @@ Fire **once per produced item** — each converted document, each converted page
51
51
52
52
See [Context Objects — Complete Guide]({{< ref "conversion/net/developer-guide/basic-usage/context-objects-complete-guide.md" >}}) for the properties exposed by `ConvertedContext`, `ConvertContext`, and `ConvertedPageContext`.
53
53
54
+
### Diagnostics
55
+
56
+
Report a condition detected while processing the source document, rather than the outcome of a produced item.
57
+
58
+
| Handler | Signature | When it fires |
59
+
|---------|-----------|---------------|
60
+
|`OnFontSubstituted`|`Action<FontSubstitutionContext>`| Once per distinct missing font in a source document, when that font is substituted during conversion |
61
+
62
+
See [Font substitution notifications](#font-substitution-notifications) below for the full handler reference.
63
+
54
64
## Registering events with the classic API
55
65
56
66
Pass a `ConversionEvents` factory as the third argument to the `Converter` constructor:
@@ -170,6 +180,99 @@ FluentConverter
170
180
171
181
The previous late-stage `.OnCompressionCompleted(stream => ...)` placed after `.Compress(...)` continues to work but is obsolete — the `IConversionCompressResultCompleted` interface that declares it is planned for removal in v26.9.
172
182
183
+
## Font substitution notifications
184
+
185
+
`OnFontSubstituted` notifies you whenever a font referenced by the source document is unavailable and gets substituted during conversion — either because the font is missing from the machine, or because you configured a [FontSubstitute](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.contracts/fontsubstitute/) rule (see [Specify font substitution]({{< ref "conversion/net/developer-guide/advanced-usage/loading/load-options-for-different-document-types/load-wordprocessing-document-with-options.md#specify-font-substitution" >}})). The handler receives a `FontSubstitutionContext` describing the substitution.
186
+
187
+
### Subscribe (classic API)
188
+
189
+
```csharp
190
+
usingGroupDocs.Conversion;
191
+
usingGroupDocs.Conversion.Contracts;
192
+
usingGroupDocs.Conversion.Options.Convert;
193
+
194
+
varevents=newConversionEvents
195
+
{
196
+
OnFontSubstituted=context=>
197
+
{
198
+
// Prefer the typed names when present; otherwise use the verbatim Reason.
### Notify on a customer-supplied substitution rule
227
+
228
+
When you provide your own substitution rules through the load options (supported for Word-processing, Spreadsheet, and PDF documents), `OnFontSubstituted` reports each rule that is applied:
|`SourceFileName`| The source document's file name (a generated id when the source is a non-file stream). |
254
+
|`OriginalFontName`| The font referenced by the document but unavailable. May be `null` for formats that report only descriptive text. |
255
+
|`SubstituteFontName`| The font used instead. May be `null` — read `Reason`. |
256
+
|`Reason`| The substitution message exactly as reported, verbatim. Names both fonts when the typed members are `null`. |
257
+
258
+
See [Context Objects — Complete Guide]({{< ref "conversion/net/developer-guide/basic-usage/context-objects-complete-guide.md#fontsubstitutioncontext" >}}) for more detail.
259
+
260
+
### Supported documents
261
+
262
+
| Document family | Missing-font substitution | Rule-driven substitution |
Image conversions are out of scope — see the behavior notes below.
268
+
269
+
### Behavior notes
270
+
271
+
- Fired once per distinct missing font per source document within a single `Convert(...)` call (deduplicated).
272
+
- Raised synchronously on the conversion thread.
273
+
- Not raised for image *source* conversions (raster images carry no fonts). Converting *to* an image still reports substitutions from the source document.
274
+
- For presentation documents, substitution is detected on Windows only.
275
+
173
276
## Compatibility with the previous API
174
277
175
278
The previous registration mechanisms continue to work, but are obsolete and planned for removal in **v26.9**:
description: "Learn how to use Context Objects in GroupDocs.Conversion for .NET v24.10+. Context objects are foundational to all delegate-based patterns."
-**Dynamic configuration**: Configure options based on actual document properties
25
25
-**Lifecycle callbacks**: Monitor conversion progress page-by-page or document-level
26
26
27
-
## The Six Context Types
27
+
## The Context Types
28
28
29
-
GroupDocs.Conversion provides six context types, each serving a specific purpose:
29
+
GroupDocs.Conversion provides six **configuration/result**context types that drive delegate-based patterns, plus one **diagnostic** context (`FontSubstitutionContext`, available since v26.6) delivered to a conversion event:
30
30
31
31
| Context Type | Used In | Purpose |
32
32
|--------------|---------|---------|
@@ -36,6 +36,7 @@ GroupDocs.Conversion provides six context types, each serving a specific purpose
36
36
|[SavePageContext](https://reference.groupdocs.com/conversion/net/groupdocs.conversion/savepagecontext/)|`Func<SavePageContext, Stream>`| Provides page-specific information for stream output |
37
37
|[ConvertedContext](https://reference.groupdocs.com/conversion/net/groupdocs.conversion/convertedcontext/)|`Action<ConvertedContext>`| Callback after entire document conversion completes |
38
38
|[ConvertedPageContext](https://reference.groupdocs.com/conversion/net/groupdocs.conversion/convertedpagecontext/)|`Action<ConvertedPageContext>`| Callback after each page conversion completes |
39
+
|[FontSubstitutionContext](#fontsubstitutioncontext)|`Action<FontSubstitutionContext>`| Diagnostic — reports a font substituted while processing the source document |
39
40
40
41
---
41
42
@@ -287,6 +288,49 @@ using (var converter = new Converter("monthly-report.pdf"))
287
288
288
289
---
289
290
291
+
## FontSubstitutionContext
292
+
293
+
**Used in**: the `OnFontSubstituted` handler of [ConversionEvents](https://reference.groupdocs.com/conversion/net/groupdocs.conversion/conversionevents/) (`Action<FontSubstitutionContext>`)
294
+
295
+
**Purpose**: Unlike the six context types above — which configure delegates or report a produced result — `FontSubstitutionContext` is a **diagnostic** context. Starting with **GroupDocs.Conversion for .NET v26.6**, it is delivered to the `OnFontSubstituted` event whenever a font referenced by the source document is unavailable and gets substituted during conversion (a missing system font, or a [FontSubstitute](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.contracts/fontsubstitute/) rule you configured).
296
+
297
+
### Properties
298
+
299
+
| Property | Type | Description |
300
+
|----------|------|-------------|
301
+
|`SourceFileName`|`string`| Name of the source file (a generated id when the source is a non-file stream) (read-only) |
302
+
|`OriginalFontName`|`string`| The font referenced by the document but unavailable. May be `null` for formats that report only descriptive text (read-only) |
303
+
|`SubstituteFontName`|`string`| The font used instead. May be `null` — read `Reason` (read-only) |
304
+
|`Reason`|`string`| The substitution message exactly as reported, verbatim. Names both fonts when the typed members are `null` (read-only) |
See [Conversion events — Font substitution notifications]({{< ref "conversion/net/developer-guide/advanced-usage/conversion-events.md#font-substitution-notifications" >}}) for the supported-document matrix and behavior notes.
331
+
332
+
---
333
+
290
334
## Working with Container Documents
291
335
292
336
The `HierarchyLevel` and `ItemIndex` properties become relevant when converting **container documents** that can hold multiple items in a hierarchical structure.
Copy file name to clipboardExpand all lines: net/getting-started/features-overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ You can obtain the [complete list of possible conversions]({{< ref "conversion/n
41
41
42
42
### Fonts replacement
43
43
44
-
It is a common use case when a source document references some specific fonts that are not present in the environment where you launch your application. GroupDocs.Conversion for .NET provides a solution - you can [substitute missing fonts]({{< ref "conversion/net/developer-guide/advanced-usage/loading/load-options-for-different-document-types/load-wordprocessing-document-with-options#specify-font-substitution" >}}) with fonts of your choice that will preserve your document appearance.
44
+
It is a common use case when a source document references some specific fonts that are not present in the environment where you launch your application. GroupDocs.Conversion for .NET provides a solution - you can [substitute missing fonts]({{< ref "conversion/net/developer-guide/advanced-usage/loading/load-options-for-different-document-types/load-wordprocessing-document-with-options#specify-font-substitution" >}}) with fonts of your choice that will preserve your document appearance. You can also [subscribe to the `OnFontSubstituted` event]({{< ref "conversion/net/developer-guide/advanced-usage/conversion-events.md#font-substitution-notifications" >}}) to be notified whenever a font is substituted during conversion.
0 commit comments