Skip to content

Commit a93e57c

Browse files
committed
HTML export examples added
1 parent c97d2bf commit a93e57c

File tree

16 files changed

+517
-11
lines changed

16 files changed

+517
-11
lines changed

Aspose.Slides.WebExtensions.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SinglePageApp", "Examples\S
99
EndProject
1010
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{1EC1A0EB-7D24-42EC-9DD9-BD7B1C0C80DE}"
1111
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiPageApp", "Examples\MultiPageApp\MultiPageApp.csproj", "{5C1CFAA5-BF54-48B7-BB88-24D090378B02}"
13+
EndProject
1214
Global
1315
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1416
Debug|Any CPU = Debug|Any CPU
@@ -23,12 +25,17 @@ Global
2325
{76F62349-ED12-451C-BDF5-8EFB6F36AEC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
2426
{76F62349-ED12-451C-BDF5-8EFB6F36AEC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
2527
{76F62349-ED12-451C-BDF5-8EFB6F36AEC7}.Release|Any CPU.Build.0 = Release|Any CPU
28+
{5C1CFAA5-BF54-48B7-BB88-24D090378B02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{5C1CFAA5-BF54-48B7-BB88-24D090378B02}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{5C1CFAA5-BF54-48B7-BB88-24D090378B02}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{5C1CFAA5-BF54-48B7-BB88-24D090378B02}.Release|Any CPU.Build.0 = Release|Any CPU
2632
EndGlobalSection
2733
GlobalSection(SolutionProperties) = preSolution
2834
HideSolutionNode = FALSE
2935
EndGlobalSection
3036
GlobalSection(NestedProjects) = preSolution
3137
{76F62349-ED12-451C-BDF5-8EFB6F36AEC7} = {1EC1A0EB-7D24-42EC-9DD9-BD7B1C0C80DE}
38+
{5C1CFAA5-BF54-48B7-BB88-24D090378B02} = {1EC1A0EB-7D24-42EC-9DD9-BD7B1C0C80DE}
3239
EndGlobalSection
3340
GlobalSection(ExtensibilityGlobals) = postSolution
3441
SolutionGuid = {2BF1759F-EF79-4CE6-BDC9-2DE792A1F1EF}

Aspose.Slides.WebExtensions/PresentationExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private static void CheckArguments(WebDocumentOptions options, string templatesP
130130
options.OutputSaver = new FileOutputSaver();
131131
}
132132

133-
private static void AddCommonInputOutput(this WebDocument document, WebDocumentOptions options, string templatesPath, string outputPath, Presentation pres)
133+
public static void AddCommonInputOutput(this WebDocument document, WebDocumentOptions options, string templatesPath, string outputPath, Presentation pres)
134134
{
135135
string stylesPath = document.Global.Get<string>("stylesPath");
136136
string scriptsPath = document.Global.Get<string>("scriptsPath");
@@ -177,7 +177,7 @@ private static void AddCommonInputOutput(this WebDocument document, WebDocumentO
177177
}
178178
}
179179

180-
private static void AddMultiPageInputTemplates(this WebDocument document, string templatesPath)
180+
public static void AddMultiPageInputTemplates(this WebDocument document, string templatesPath)
181181
{
182182
document.Input.AddTemplate<Presentation>("menu", Path.Combine(templatesPath, "menu.html"));
183183
}
@@ -215,7 +215,7 @@ private static void AddImagesOutput(this WebDocument document, string outputPath
215215
}
216216
}
217217

218-
private static void AddThumbnailsOutput(this WebDocument document, string outputPath, Presentation pres)
218+
public static void AddThumbnailsOutput(this WebDocument document, string outputPath, Presentation pres)
219219
{
220220
for (int index = 1; index <= pres.Slides.Count; index++)
221221
{
@@ -276,7 +276,7 @@ private static void AddShapeAsImagesOutput<T>(this WebDocument document, string
276276
}
277277
}
278278

279-
private static void AddEmbeddedFontsOutput(this WebDocument document, string outFontsFolder, Presentation pres)
279+
public static void AddEmbeddedFontsOutput(this WebDocument document, string outFontsFolder, Presentation pres)
280280
{
281281
IFontData[] embeddedFonts = pres.FontsManager.GetEmbeddedFonts();
282282

@@ -293,7 +293,7 @@ private static void AddEmbeddedFontsOutput(this WebDocument document, string out
293293
}
294294
}
295295

296-
private static void AddVideoOutput(this WebDocument document, string outputPath, Presentation pres)
296+
public static void AddVideoOutput(this WebDocument document, string outputPath, Presentation pres)
297297
{
298298
List<VideoFrame> videoFrames = ShapeHelper.GetListOfShapes<VideoFrame>(pres);
299299

@@ -308,7 +308,7 @@ private static void AddVideoOutput(this WebDocument document, string outputPath,
308308
}
309309
}
310310

311-
private static void AddScriptsOutput(this WebDocument document, string outputPath, string inputFile, string scriptName)
311+
public static void AddScriptsOutput(this WebDocument document, string outputPath, string inputFile, string scriptName)
312312
{
313313
string scriptContent;
314314
using (var fs = File.Open(inputFile, FileMode.Open))

Aspose.Slides.WebExtensions/Templates/multi-page/slide.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,24 @@
6060
<div class="slide master-bg">
6161
@foreach (var shape in contextObject.LayoutSlide.MasterSlide.Shapes)
6262
{
63-
if(shape.Placeholder == null) {
64-
@EmitShape(shape, contextObject, animateTransitions, slideNumber);
63+
var subModel = Model.SubModel((VideoFrame)shape);
64+
subModel.Local.Put<Point>("origin", origin);
65+
66+
@Include("videoframe", subModel)
67+
}
68+
else if (shape is PictureFrame)
69+
{
70+
var subModel = Model.SubModel((PictureFrame)shape);
71+
subModel.Local.Put("origin", origin);
72+
73+
@Include("pictureframe", subModel)
74+
}
75+
else if (shape is Table)
76+
{
77+
var subModel = Model.SubModel((Table)shape);
78+
subModel.Local.Put("origin", origin);
79+
80+
@Include("table", subModel)
6581
}
6682
}
6783

Examples/Data/table.pptx

31.9 KB
Binary file not shown.

Examples/MultiPageApp/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{5C1CFAA5-BF54-48B7-BB88-24D090378B02}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>MultiPageApp</RootNamespace>
10+
<AssemblyName>MultiPageApp</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Aspose.Slides, Version=21.2.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Aspose.Slides.NET.21.2.0\lib\net4.0-client\Aspose.Slides.dll</HintPath>
38+
</Reference>
39+
<Reference Include="System" />
40+
<Reference Include="System.Core" />
41+
<Reference Include="System.Drawing" />
42+
<Reference Include="System.Xml.Linq" />
43+
<Reference Include="System.Data.DataSetExtensions" />
44+
<Reference Include="Microsoft.CSharp" />
45+
<Reference Include="System.Data" />
46+
<Reference Include="System.Net.Http" />
47+
<Reference Include="System.Xml" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="Program.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<None Include="App.config" />
55+
<None Include="packages.config" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<ProjectReference Include="..\..\Aspose.Slides.WebExtensions\Aspose.Slides.WebExtensions.csproj">
59+
<Project>{3fa3c3d2-b915-4c39-978c-b836638d655c}</Project>
60+
<Name>Aspose.Slides.WebExtensions</Name>
61+
</ProjectReference>
62+
</ItemGroup>
63+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
64+
<PropertyGroup>
65+
<PostBuildEvent>xcopy /e /y /i /r "$(TargetDir)Templates\common\*.*" "$(TargetDir)Templates\multi-page\"
66+
xcopy /y "$(ProjectDir)..\Data\demo.pptx" "$(TargetDir)"
67+
xcopy /y "$(ProjectDir)..\Data\demo-transitions.pptx" "$(TargetDir)"</PostBuildEvent>
68+
</PropertyGroup>
69+
</Project>

Examples/MultiPageApp/Program.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using Aspose.Slides;
2+
using Aspose.Slides.Export.Web;
3+
using Aspose.Slides.WebExtensions;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace MultiPageApp
12+
{
13+
class Program
14+
{
15+
static void Main(string[] args)
16+
{
17+
ExportBySections();
18+
19+
Console.WriteLine("HTML export is complete...");
20+
}
21+
22+
static void ExportBySections()
23+
{
24+
using (Presentation pres = new Presentation("demo-transitions.pptx"))
25+
{
26+
const string templatesPath = "templates\\multi-page";
27+
const string outputPath = "multi-page-by-sections";
28+
29+
var options = new WebDocumentOptions
30+
{
31+
TemplateEngine = new RazorTemplateEngine(),
32+
OutputSaver = new FileOutputSaver(),
33+
EmbedImages = false
34+
};
35+
36+
// setup global document values
37+
WebDocument document = new WebDocument(options);
38+
PresentationExtensions.SetGlobals(document, options, outputPath);
39+
string slidesPath = Path.Combine(outputPath, "slides");
40+
string stylesPath = Path.Combine(outputPath, "styles");
41+
string scriptsPath = Path.Combine(outputPath, "scripts");
42+
43+
document.Global.Put("slidesPath", slidesPath);
44+
document.Global.Put("stylesPath", stylesPath);
45+
document.Global.Put("scriptsPath", scriptsPath);
46+
47+
// setup folder-by-section folders structure
48+
foreach (ISection section in pres.Sections)
49+
{
50+
foreach (Slide slide in section.GetSlidesListOfSection())
51+
{
52+
if (slide.Hidden)
53+
continue;
54+
55+
string path = Path.Combine(
56+
outputPath, section.Name,
57+
string.Format("slide{0}.html", slide.SlideNumber));
58+
59+
document.Output.Add(path, "slide", slide);
60+
}
61+
}
62+
63+
// setup rest of the document properties
64+
document.AddCommonInputOutput(options, templatesPath, outputPath, pres);
65+
66+
document.AddMultiPageInputTemplates(templatesPath);
67+
document.Output.Add(Path.Combine(outputPath, "menu.html"), "menu", pres);
68+
69+
if (!options.EmbedImages)
70+
{
71+
document.AddThumbnailsOutput(document.Global.Get<string>("imagesPath"), pres);
72+
}
73+
74+
document.Save();
75+
}
76+
}
77+
}
78+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("MultiPageApp")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("MultiPageApp")]
13+
[assembly: AssemblyCopyright("Copyright © 2021")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("5c1cfaa5-bf54-48b7-bb88-24d090378b02")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

Examples/MultiPageApp/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Aspose.Slides.NET" version="21.2.0" targetFramework="net472" />
4+
</packages>

0 commit comments

Comments
 (0)