Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Custom-font-registration/Custom-font-registration.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Custom_font_registration</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIORenderer.NET" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Template.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Fonts\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIO;
using Syncfusion.DocIORenderer;
using Syncfusion.Drawing.Fonts;

namespace Custom_font_registration
{
internal class Program
{
static void Main(string[] args)
{
FontManager.RegisterFonts(Path.GetFullPath(@"Fonts"));
List<string> registeredFontNames = FontManager.RegisteredFontNames;
ConvertWordToImage();
FontManager.ClearRegisteredFonts(true);
}

static void ConvertWordToImage()
{
// Load the Word document
using (WordDocument wordDocument = new WordDocument(Path.GetFullPath(@"Data/Template.docx"), FormatType.Automatic))
{
using (DocIORenderer renderer = new DocIORenderer())
{
// Convert the entire Word document to images
Stream[] imageStreams = wordDocument.RenderAsImages();

for (int i = 0; i < imageStreams.Length; i++)
{
// Save each page as an image
string savePath = Path.GetFullPath($@"Output/Page_{i + 1}.jpeg");

using (FileStream outputStream = File.Create(savePath))
{
imageStreams[i].CopyTo(outputStream);
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Custom-font-registration/Custom-font-registration.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Custom_font_registration</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.DocIORenderer.NET" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Template.docx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Fonts\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Syncfusion.DocIO.DLS;
using Syncfusion.DocIO;
using Syncfusion.DocIORenderer;
using Syncfusion.Pdf;
using Syncfusion.Drawing.Fonts;

namespace Custom_font_registration
{
internal class Program
{
public static void Main(string[] args)
{
FontManager.RegisterFonts(Path.GetFullPath(@"Fonts"));
List<string> registeredFontNames = FontManager.RegisteredFontNames;
ConvertWordToPDF();
FontManager.ClearRegisteredFonts(true);
}

private static void ConvertWordToPDF()
{
// Loads an existing Word document
using (WordDocument wordDocument = new WordDocument(Path.GetFullPath(@"Data/Template.docx"), FormatType.Automatic))
{
// Creates an instance of DocIORenderer
using (DocIORenderer renderer = new DocIORenderer())
{
// Converts Word document into PDF document
using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))
{
// Saves the PDF document
pdfDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
}
}
}
}
}
}
Loading