Skip to content

Commit 8434083

Browse files
Committing the sample for Convert-Word-to-EPUB in WPF
1 parent 069c85d commit 8434083

File tree

9 files changed

+144
-0
lines changed

9 files changed

+144
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34205.153
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Convert-Word-to-EPUB", "Convert-Word-to-EPUB\Convert-Word-to-EPUB.csproj", "{45BC28F8-936A-43D7-9BE1-6D7F5E2E1FF0}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{45BC28F8-936A-43D7-9BE1-6D7F5E2E1FF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{45BC28F8-936A-43D7-9BE1-6D7F5E2E1FF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{45BC28F8-936A-43D7-9BE1-6D7F5E2E1FF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{45BC28F8-936A-43D7-9BE1-6D7F5E2E1FF0}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {1EDAAF90-6753-4AFD-AE3D-1D498867F0C7}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Application x:Class="Convert_Word_to_EPUB.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:Convert_Word_to_EPUB"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
8+
</Application.Resources>
9+
</Application>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Configuration;
2+
using System.Data;
3+
using System.Windows;
4+
5+
namespace Convert_Word_to_EPUB
6+
{
7+
/// <summary>
8+
/// Interaction logic for App.xaml
9+
/// </summary>
10+
public partial class App : Application
11+
{
12+
}
13+
14+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<RootNamespace>Convert_Word_to_EPUB</RootNamespace>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<UseWPF>true</UseWPF>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Syncfusion.DocIO.Wpf" Version="*" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
<ItemGroup>
5+
<ApplicationDefinition Update="App.xaml">
6+
<SubType>Designer</SubType>
7+
</ApplicationDefinition>
8+
</ItemGroup>
9+
<ItemGroup>
10+
<Page Update="MainWindow.xaml">
11+
<SubType>Designer</SubType>
12+
</Page>
13+
</ItemGroup>
14+
</Project>
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Window x:Class="Convert_Word_to_EPUB.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:Convert_Word_to_EPUB"
7+
mc:Ignorable="d"
8+
Title="MainWindow" Height="450" Width="800">
9+
<Grid>
10+
<Button Click="btnWordToEPUB_Click" Margin="0,196,315,0" VerticalAlignment="Top" Height="30" BorderBrush="LightBlue" HorizontalAlignment="Right" Width="180">
11+
<Button.Background>
12+
<LinearGradientBrush EndPoint="0.5,-0.04" StartPoint="0.5,1.04">
13+
<GradientStop Color="#FFD9E9F7" Offset="0"/>
14+
<GradientStop Color="#FFEFF8FF" Offset="1"/>
15+
</LinearGradientBrush>
16+
</Button.Background>
17+
<StackPanel Orientation="Horizontal" Height="23" Margin="0,0,0,-2.52" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="100">
18+
<Image Name="image2" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" />
19+
<TextBlock Text="Word to EPUB" Height="15.96" Width="126" Margin="0,4,0,3" />
20+
</StackPanel>
21+
</Button>
22+
</Grid>
23+
</Window>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.IO;
2+
using System.Windows;
3+
using Syncfusion.DocIO;
4+
using Syncfusion.DocIO.DLS;
5+
6+
namespace Convert_Word_to_EPUB
7+
{
8+
/// <summary>
9+
/// Interaction logic for MainWindow.xaml
10+
/// </summary>
11+
public partial class MainWindow : Window
12+
{
13+
public MainWindow()
14+
{
15+
InitializeComponent();
16+
}
17+
private void btnWordToEPUB_Click(object sender, RoutedEventArgs e)
18+
{
19+
//Open an existing Word document.
20+
            using (WordDocument document = new WordDocument(Path.GetFullPath(@"../../../Data/Input.docx"), FormatType.Automatic))
21+
{
22+
//Exports the fonts used in the document
23+
document.SaveOptions.EPubExportFont = true;
24+
//Exports header and footer
25+
document.SaveOptions.HtmlExportHeadersFooters = true;
26+
27+
//Save the Word document.
28+
document.Save(@"../../../WordToEPUB.epub", FormatType.EPub);
29+
}
30+
MessageBox.Show("Word document generated successfully");
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)