Skip to content

Commit 2d0fe7b

Browse files
committed
Multi-page updated to support custom slide path
1 parent 0ad1908 commit 2d0fe7b

File tree

6 files changed

+49
-34
lines changed

6 files changed

+49
-34
lines changed

Aspose.Slides.WebExtensions/Aspose.Slides.WebExtensions.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
<Content Include="Templates\common\scripts\jquery-3.5.1.min.js">
7777
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7878
</Content>
79+
<Content Include="Templates\common\scripts\navigation.js">
80+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
81+
</Content>
7982
<Content Include="Templates\common\shape.html">
8083
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8184
</Content>
@@ -109,6 +112,12 @@
109112
<Content Include="Templates\multi-page\slide.html">
110113
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
111114
</Content>
115+
<Content Include="Templates\single-page-navigation\index.html">
116+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
117+
</Content>
118+
<Content Include="Templates\single-page-navigation\slide.html">
119+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
120+
</Content>
112121
<Content Include="Templates\single-page\index.html">
113122
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
114123
</Content>

Aspose.Slides.WebExtensions/PresentationExtensions.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public static WebDocument ToMultiPageWebDocument(
9393

9494
SetGlobals(document, options, outputPath);
9595

96-
string slidesPath = Path.Combine(outputPath, "slides");
96+
const string localSlidesPath = "slides";
97+
98+
string slidesPath = Path.Combine(outputPath, localSlidesPath);
9799
string stylesPath = Path.Combine(outputPath, "styles");
98100
string scriptsPath = Path.Combine(outputPath, "scripts");
99101

@@ -104,7 +106,7 @@ public static WebDocument ToMultiPageWebDocument(
104106
document.AddCommonInputOutput(options, templatesPath, outputPath, pres);
105107

106108
document.AddMultiPageInputTemplates(templatesPath);
107-
document.AddMultiPageOutputFiles(slidesPath, pres);
109+
document.AddMultiPageOutputFiles(outputPath, slidesPath, localSlidesPath, pres);
108110

109111
if (!options.EmbedImages)
110112
document.AddThumbnailsOutput(document.Global.Get<string>("imagesPath"), pres);
@@ -182,7 +184,7 @@ public static void AddMultiPageInputTemplates(this WebDocument document, string
182184
document.Input.AddTemplate<Presentation>("menu", Path.Combine(templatesPath, "menu.html"));
183185
}
184186

185-
private static void AddMultiPageOutputFiles(this WebDocument document, string outputPath, Presentation pres)
187+
private static void AddMultiPageOutputFiles(this WebDocument document, string outputPath, string slidesPath, string localSlidesPath, Presentation pres)
186188
{
187189
document.Output.Add(Path.Combine(outputPath, "menu.html"), "menu", pres);
188190

@@ -191,7 +193,13 @@ private static void AddMultiPageOutputFiles(this WebDocument document, string ou
191193
if (slide.Hidden)
192194
continue;
193195

194-
document.Output.Add(Path.Combine(outputPath, string.Format("slide{0}.html", slide.SlideNumber)), "slide", slide);
196+
string subPath = Path.Combine(string.Format("slide{0}.html", slide.SlideNumber));
197+
string path = Path.Combine(slidesPath, subPath);
198+
document.Output.Add(path, "slide", slide);
199+
200+
string key = string.Format("slide{0}path", slide.SlideNumber);
201+
document.Global.Put(key, Path.Combine(localSlidesPath, subPath));
202+
195203
}
196204
}
197205

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
@{
44
Presentation contextObject = Model.Object;
5+
string slide1Path = Model.Global.Get<string>("slide1path");
56
}
67

78
<!DOCTYPE html>
@@ -14,8 +15,8 @@
1415
<link rel="stylesheet" type="text/css" href="styles\master.css" />
1516
</head>
1617
<frameset cols="225, *">
17-
<frame src="slides\menu.html" name="menu_page" />
18-
<frame src="slides\slide1.html" name="slide_page" />
18+
<frame src="menu.html" name="menu_page" />
19+
<frame src="@slide1Path" name="slide_page" />
1920

2021
<noframes>
2122
<body>Your browser does not support frames.</body>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@model TemplateContext<Presentation>
1+
@model TemplateContext<Presentation>
22

33
@{
44
Presentation contextObject = Model.Object;
@@ -9,8 +9,8 @@
99
<html xmlns="http://www.w3.org/1999/xhtml">
1010
<head>
1111
<meta charset="utf-8" />
12-
<link rel="stylesheet" type="text/css" href="..\styles\pres.css" />
13-
<link rel="stylesheet" type="text/css" href="..\styles\master.css" />
12+
<link rel="stylesheet" type="text/css" href="styles\pres.css" />
13+
<link rel="stylesheet" type="text/css" href="styles\master.css" />
1414
</head>
1515
<body>
1616
<br />
@@ -22,8 +22,8 @@
2222
continue;
2323
}
2424

25-
var slidePage = "slide" + slide.SlideNumber + ".html";
26-
var thumbnailSource = "..\\images\\thumbnail" + slide.SlideNumber + ".png";
25+
var slidePage = Model.Global.Get<string>("slide" + slide.SlideNumber + "path");
26+
var thumbnailSource = "images\\thumbnail" + slide.SlideNumber + ".png";
2727

2828
if (Model.Global.Get<bool>("embedImages"))
2929
{

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

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,8 @@
6060
<div class="slide master-bg">
6161
@foreach (var shape in contextObject.LayoutSlide.MasterSlide.Shapes)
6262
{
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)
63+
if(shape.Placeholder == null) {
64+
@EmitShape(shape, contextObject, animateTransitions, slideNumber);
8165
}
8266
}
8367

Examples/MultiPageApp/Program.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,20 @@ class Program
1414
{
1515
static void Main(string[] args)
1616
{
17-
ExportBySections();
17+
ExportDefault();
1818

1919
Console.WriteLine("HTML export is complete...");
2020
}
2121

22+
static void ExportDefault()
23+
{
24+
using (Presentation pres = new Presentation("demo.pptx"))
25+
{
26+
WebDocument document = pres.ToMultiPageWebDocument("templates\\multi-page", @"mutil-page-output");
27+
document.Save();
28+
}
29+
}
30+
2231
static void ExportBySections()
2332
{
2433
using (Presentation pres = new Presentation("demo-transitions.pptx"))
@@ -36,7 +45,9 @@ static void ExportBySections()
3645
// setup global document values
3746
WebDocument document = new WebDocument(options);
3847
PresentationExtensions.SetGlobals(document, options, outputPath);
39-
string slidesPath = Path.Combine(outputPath, "slides");
48+
49+
const string localSlidesPath = "slides";
50+
string slidesPath = Path.Combine(outputPath, localSlidesPath);
4051
string stylesPath = Path.Combine(outputPath, "styles");
4152
string scriptsPath = Path.Combine(outputPath, "scripts");
4253

@@ -52,9 +63,11 @@ static void ExportBySections()
5263
if (slide.Hidden)
5364
continue;
5465

55-
string path = Path.Combine(
56-
outputPath, section.Name,
57-
string.Format("slide{0}.html", slide.SlideNumber));
66+
string subPath = Path.Combine(section.Name, string.Format("slide{0}.html", slide.SlideNumber));
67+
string path = Path.Combine(outputPath, subPath);
68+
69+
string key = string.Format("slide{0}path", slide.SlideNumber);
70+
document.Global.Put(key, subPath);
5871

5972
document.Output.Add(path, "slide", slide);
6073
}

0 commit comments

Comments
 (0)