Skip to content

Commit ad8a4f5

Browse files
1051610- Added GitHub example samples for custom font registration in Word to PDF and Image Conversion
1 parent 0fe8d41 commit ad8a4f5

24 files changed

Lines changed: 109 additions & 0 deletions

File tree

Binary file not shown.
Binary file not shown.
Binary file not shown.

‎Word-to-Image-conversion/Custom-font-registration/.NET/Custom-font-registration/Output/.gitkeep‎

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
using Syncfusion.DocIORenderer;
4+
using Syncfusion.Drawing.Fonts;
5+
6+
namespace Custom_font_registration
7+
{
8+
internal class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
FontManager.RegisterFonts(Path.GetFullPath(@"Fonts"));
13+
List<string> registeredFontNames = FontManager.RegisteredFontNames;
14+
ConvertWordToImage();
15+
FontManager.ClearRegisteredFonts(true);
16+
}
17+
18+
static void ConvertWordToImage()
19+
{
20+
// Load the Word document
21+
using (WordDocument wordDocument = new WordDocument(Path.GetFullPath(@"Data/Template.docx"), FormatType.Automatic))
22+
{
23+
using (DocIORenderer renderer = new DocIORenderer())
24+
{
25+
// Convert the entire Word document to images
26+
Stream[] imageStreams = wordDocument.RenderAsImages();
27+
28+
for (int i = 0; i < imageStreams.Length; i++)
29+
{
30+
// Save each page as an image
31+
string savePath = Path.GetFullPath($@"Output/Page_{i + 1}.jpeg");
32+
33+
using (FileStream outputStream = File.Create(savePath))
34+
{
35+
imageStreams[i].CopyTo(outputStream);
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Solution>
2+
<Project Path="Custom-font-registration/Custom-font-registration.csproj" />
3+
</Solution>

0 commit comments

Comments
 (0)