Skip to content

Commit c91b3d4

Browse files
author
KB Bot
committed
Added new kb article fixing-double-bold-text-issue-in-pdf-document
1 parent 7aad9b7 commit c91b3d4

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: Resolving Double-Bold Appearance in PDF Export Using Telerik WordsProcessing
3+
description: Learn how to resolve the double-bold 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: words,processing, pdf, pdfformatprovider, font,embed, arial-narrow, register
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 PDF viewers 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+
23+
This knowledge base article also answers the following questions:
24+
- How to fix bold text rendering issues in PDFs generated by Telerik WordsProcessing?
25+
- Why does the bold text in PDFs look thicker than expected?
26+
- How to correctly embed Arial Narrow Bold in Telerik WordsProcessing?
27+
28+
## Solution
29+
30+
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:
31+
32+
1. Register the correct font files at the start of your application using `FontsRepository.RegisterFont`. This ensures that the library uses the appropriate font variations for bold and italic.
33+
34+
```csharp
35+
FontsRepository.RegisterFont(new System.Windows.Media.FontFamily("Arial Narrow"), FontStyles.Normal, FontWeights.Bold,
36+
File.ReadAllBytes(@"C:\WINDOWS\FONTS\ARIALNB.TTF"));
37+
FontsRepository.RegisterFont(new System.Windows.Media.FontFamily("Arial Narrow"), FontStyles.Italic, FontWeights.Normal,
38+
File.ReadAllBytes(@"C:\WINDOWS\FONTS\ARIALNI.TTF"));
39+
FontsRepository.RegisterFont(new System.Windows.Media.FontFamily("Arial Narrow"), FontStyles.Italic, FontWeights.Bold,
40+
File.ReadAllBytes(@"C:\WINDOWS\FONTS\ARIALNBI.TTF"));
41+
```
42+
43+
2. Define a style for the references section to apply the correct font family and weight settings.
44+
45+
```csharp
46+
Telerik.Windows.Documents.Flow.Model.Styles.Style referenceStyleChar = new Telerik.Windows.Documents.Flow.Model.Styles.Style("ReferenceStyleChar", StyleType.Character);
47+
referenceStyleChar.Name = "Reference Style Char";
48+
referenceStyleChar.CharacterProperties.FontFamily.LocalValue = new ThemableFontFamily("Arial Narrow");
49+
referenceStyleChar.CharacterProperties.FontStyle.LocalValue = FontStyles.Normal;
50+
referenceStyleChar.CharacterProperties.FontWeight.LocalValue = FontWeights.Bold;
51+
document.StyleRepository.Add(referenceStyleChar);
52+
```
53+
54+
3. Apply the style to the desired text or runs in your document.
55+
56+
```csharp
57+
foreach (var referenceParagraph in referenceParagraphs)
58+
{
59+
foreach (var inline in referenceParagraph.Inlines)
60+
{
61+
Run run = inline as Run;
62+
if (run != null)
63+
{
64+
run.StyleId = "ReferenceStyleChar";
65+
}
66+
}
67+
}
68+
```
69+
70+
4. Use the `FontEmbeddingType.Subset` setting when exporting to PDF to avoid redundant font embedding.
71+
72+
```csharp
73+
PdfFormatProvider PDFprovider = new PdfFormatProvider();
74+
PDFprovider.ExportSettings = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExportSettings
75+
{
76+
FontEmbeddingType = FontEmbeddingType.Subset
77+
};
78+
79+
using (Stream output = File.OpenWrite(Server.MapPath("~/App_Data/Output.pdf")))
80+
{
81+
PDFprovider.Export(document, output, TimeSpan.FromSeconds(10));
82+
}
83+
```
84+
85+
5. Test the exported PDF in different viewers to confirm that the bold text appears correctly without the "double-bold" effect.
86+
87+
## See Also
88+
89+
- [WordsProcessing Overview](https://docs.telerik.com/devtools/document-processing/libraries/radwordsprocessing/overview)
90+
- [PdfFormatProvider](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/pdfformatprovider/overview)
91+
- [FontEmbeddingType Enum](https://docs.telerik.com/devtools/document-processing/api/telerik.windows.documents.flow.formatproviders.pdf.export.fontembeddingtype)
92+
- [RegisterFont Method](https://docs.telerik.com/devtools/document-processing/api/telerik.windows.documents.flow.model.fonts.fontrepository#registerfont)
93+
- [System.Windows.Media.Typeface.TryGetGlyphTypeface Issue](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.typeface.trygetglyphtypeface?redirectedfrom=MSDN)
94+
95+

0 commit comments

Comments
 (0)