Skip to content

Commit 38029ca

Browse files
authored
Merge pull request #637 from telerik/new-kb-fixing-double-bold-text-issue-in-pdf-document-56ad60942fec4912b2725bcd7b5ce391
Added new kb article fixing-double-bold-text-issue-in-pdf-document
2 parents 93c38fe + 344cc26 commit 38029ca

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Resolving Double-Bold Text Appearance in PDF Export Using Telerik Document Processing
3+
description: Learn how to resolve the double-bold text appearance issue in PDFs generated by Telerik WordsProcessing using font registration and style configuration.
4+
type: how-to
5+
page_title: Fixing Double-Bold Text Issue in PDFs Exported from Telerik WordsProcessing
6+
meta_title: Fixing Double-Bold Text Issue in PDFs Exported from Telerik WordsProcessing
7+
slug: fixing-double-bold-text-issue-in-pdf-document
8+
tags: word, processing, pdf, provider, font, embed, arial, narrow, register, bold, flow, double, export
9+
res_type: kb
10+
ticketid: 1698628
11+
---
12+
13+
## Environment
14+
15+
| Version | Product | Author |
16+
| ---- | ---- | ---- |
17+
| 2025.3.806| RadPdfProcessing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
18+
19+
## Description
20+
21+
When exporting documents to PDF using Telerik WordsProcessing, the bold text may appear "double-bold" in browsers like Edge or Chrome. This issue arises due to font embedding settings or inaccuracies in font file access, specifically with condensed fonts like Arial Narrow Bold.
22+
This knowledge base article gives some tips on how to fix double-bold text rendering issues in PDFs generated by Telerik WordsProcessing.
23+
24+
## Solution
25+
26+
The "double bold" text appearance in PDF viewers like Edge or Chrome is typically caused by font embedding. Using [FontEmbeddingType.Full]({%slug radpdfprocessing-formats-and-conversion-pdf-settings%}) can sometimes cause duplication if both regular and bold font variants are embedded and the viewer applies bold rendering on top. If your style already sets bold, avoid setting the Run.FontWeight property to FontWeights.Bold again. Double-assigning bold can lead to rendering issues.
27+
28+
To resolve the double-bold appearance issue, manually register the correct font files for Arial Narrow Bold and configure the style settings properly. Follow these steps:
29+
30+
1. Register the correct font files at the start of your application using FontsRepository.[RegisterFont]({%slug radpdfprocessing-concepts-fonts%}#registering-a-font). This ensures that the library uses the appropriate font variations for bold and italic.
31+
32+
```csharp
33+
FontsRepository.RegisterFont(new System.Windows.Media.FontFamily("Arial Narrow"), FontStyles.Normal, FontWeights.Bold,
34+
File.ReadAllBytes(@"C:\WINDOWS\FONTS\ARIALNB.TTF"));
35+
FontsRepository.RegisterFont(new System.Windows.Media.FontFamily("Arial Narrow"), FontStyles.Italic, FontWeights.Normal,
36+
File.ReadAllBytes(@"C:\WINDOWS\FONTS\ARIALNI.TTF"));
37+
FontsRepository.RegisterFont(new System.Windows.Media.FontFamily("Arial Narrow"), FontStyles.Italic, FontWeights.Bold,
38+
File.ReadAllBytes(@"C:\WINDOWS\FONTS\ARIALNBI.TTF"));
39+
```
40+
41+
2. Define a [style]({%slug radwordsprocessing-concepts-styles%}) for the desired section to apply the correct font family and weight settings.
42+
43+
```csharp
44+
Telerik.Windows.Documents.Flow.Model.Styles.Style referenceStyleChar = new Telerik.Windows.Documents.Flow.Model.Styles.Style("ReferenceStyleChar", StyleType.Character);
45+
referenceStyleChar.Name = "Reference Style Char";
46+
referenceStyleChar.CharacterProperties.FontFamily.LocalValue = new ThemableFontFamily("Arial Narrow");
47+
referenceStyleChar.CharacterProperties.FontStyle.LocalValue = FontStyles.Normal;
48+
referenceStyleChar.CharacterProperties.FontWeight.LocalValue = FontWeights.Bold;
49+
document.StyleRepository.Add(referenceStyleChar);
50+
```
51+
52+
3. Apply the style to the desired text or [Runs]({%slug radwordsprocessing-model-run%}) in your document.
53+
54+
```csharp
55+
foreach (var referenceParagraph in referenceParagraphs)
56+
{
57+
foreach (var inline in referenceParagraph.Inlines)
58+
{
59+
Run run = inline as Run;
60+
if (run != null)
61+
{
62+
run.StyleId = "ReferenceStyleChar";
63+
}
64+
}
65+
}
66+
```
67+
68+
4. Use the `FontEmbeddingType.Subset` setting when [exporting to PDF]({%slug radwordsprocessing-formats-and-conversion-pdf-settings%}) to avoid redundant font embedding.
69+
70+
```csharp
71+
PdfFormatProvider PDFprovider = new PdfFormatProvider();
72+
PDFprovider.ExportSettings = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExportSettings
73+
{
74+
FontEmbeddingType = FontEmbeddingType.Subset
75+
};
76+
77+
using (Stream output = File.OpenWrite(Server.MapPath("~/App_Data/Output.pdf")))
78+
{
79+
PDFprovider.Export(document, output, TimeSpan.FromSeconds(10));
80+
}
81+
```
82+
83+
5. Test the exported PDF in different viewers to confirm that the bold text appears correctly without the "double-bold" effect.
84+
85+
## See Also
86+
87+
- [Fonts in PdfProcessing]({%slug radpdfprocessing-concepts-fonts%})
88+
89+

libraries/radpdfprocessing/concepts/fonts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,4 @@ You can create fonts that are not explicitly registered. Creating a font that is
169169
* [How to Prevent Text with Special Characters from Being Cut Off when converting HTML to PDF using RadWordsProcessing]({%slug prevent-text-cut-off-pdf-conversion-radwordsprocessing%})
170170
* [Validating Fonts when Using Telerik Document Processing]({%slug validating-fonts-pdf-document-processing%})
171171
* [Resolving Apostrophe Character Being Replaced with Copyright Symbol in Filled PDF AcroForm]({%slug apostrophe-character-replaced-copyright-symbol-acroform%})
172+
* [Resolving Double-Bold Text Appearance in PDF Export Using Telerik Document Processing]({%slug fixing-double-bold-text-issue-in-pdf-document%})

0 commit comments

Comments
 (0)