Skip to content
This repository was archived by the owner on Jul 26, 2021. It is now read-only.
Open
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
6 changes: 3 additions & 3 deletions src/GroupDocs.Editor.MVC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<HintPath>..\packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="GroupDocs.Editor, Version=20.8.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
<HintPath>..\packages\GroupDocs.Editor.20.8.0\lib\net20\GroupDocs.Editor.dll</HintPath>
<Reference Include="GroupDocs.Editor, Version=20.10.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
<HintPath>..\packages\GroupDocs.Editor.20.10.0\lib\net40\GroupDocs.Editor.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp">
<Private>True</Private>
Expand Down Expand Up @@ -278,7 +278,7 @@
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\MSBuildTasks.1.5.0.235\build\MSBuildTasks.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSBuildTasks.1.5.0.235\build\MSBuildTasks.targets'))" />
</Target>
<Target Name="BeforeBuild">
<Target Name="BeforeBuild" DependsOnTargets="PrepareForBuild">
<Exec WorkingDirectory="client\" Command="..\..\packages\Node-Kit.11.1.0.1\node\win\node.exe ..\..\packages\Node-Kit.11.1.0.1\npm\bin\npm-cli.js install" Condition=" '$(OS)' == 'Windows_NT' " />
<Exec WorkingDirectory="client\" Command="..\..\packages\Node-Kit.11.1.0.1\node\win\node.exe ..\..\packages\Node-Kit.11.1.0.1\npm\bin\npm-cli.js run build --scripts-prepend-node-path" Condition=" '$(OS)' == 'Windows_NT' " />
</Target>
Expand Down
54 changes: 42 additions & 12 deletions src/Products/Editor/Controllers/EditorApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Http;
using System.Web.Http.Cors;
Expand Down Expand Up @@ -286,6 +287,11 @@ public HttpResponseMessage SaveFile(EditDocumentRequest postedData)
saveOptions.EnablePagination = true;
}

if (saveOptions is PresentationSaveOptions)
{
saveOptions.SlideNumber = postedData.getPageNumber() + 1;
}

using (FileStream outputStream = File.Create(tempPath))
{
editor.Save(htmlContentDoc, outputStream, saveOptions);
Expand Down Expand Up @@ -666,20 +672,44 @@ private LoadDocumentEntity LoadDocument(string guid, string password)
{
for (var i = 0; i < documentInfo.PageCount; i++)
{
// Create editing options
PresentationEditOptions presentationEditOptions = new PresentationEditOptions();
// Specify slide index from original document.
editOptions.SlideNumber = i; // Because index is 0-based, it is 1st slide
EditableDocument slideBeforeEdit = editor.Edit(presentationEditOptions);

// Get document as a single base64-encoded string, where all resources (images, fonts, etc)
// are embedded inside this string along with main textual content
string allEmbeddedInsideString = slideBeforeEdit.GetEmbeddedHtml();
PageDescriptionEntity page = new PageDescriptionEntity();
page.SetData(allEmbeddedInsideString);
page.number = i + 1;
loadDocumentEntity.SetPages(page);
slideBeforeEdit.Dispose();
using (EditableDocument slideBeforeEdit = editor.Edit(editOptions))
{
// Get document as a single base64-encoded string, where all resources (images, fonts, etc)
// are embedded inside this string along with main textual content
string allEmbeddedInsideString = slideBeforeEdit.GetEmbeddedHtml();
PageDescriptionEntity page = new PageDescriptionEntity();
if (allEmbeddedInsideString.IndexOf(".slide") > 0)
{
// TODO: extract from controller
string regex = @"\.slide.{(.*?)}";
Match match = Regex.Match(allEmbeddedInsideString, regex, RegexOptions.IgnoreCase);
if (match.Success)
{
string rules = match.Groups[1].Value.Trim().TrimEnd(';');
Dictionary<string, string> keyValuePairs = rules.Split(';')
.Select(value => value.Split(':'))
.ToDictionary(pair => pair[0].Trim(), pair => pair[1].Trim());

if (keyValuePairs.ContainsKey("height")) {
string height = string.Empty;
keyValuePairs.TryGetValue("height", out height);
page.height = Convert.ToDouble(height.Replace("pt", "").Replace("px", ""));
}

if (keyValuePairs.ContainsKey("width"))
{
string width = string.Empty;
keyValuePairs.TryGetValue("width", out width);
page.width = Convert.ToDouble(width.Replace("pt", "").Replace("px", ""));
}
}
}
page.SetData(allEmbeddedInsideString);
page.number = i + 1;
loadDocumentEntity.SetPages(page);
}
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/Products/Editor/Entity/Web/Request/EditDocumentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class EditDocumentRequest : LoadDocumentEntity
[JsonProperty]
private String password;

[JsonProperty]
private int pageNumber;

public String getContent()
{
return content;
Expand All @@ -34,5 +37,15 @@ public void setPassword(String password)
{
this.password = password;
}

public int getPageNumber()
{
return pageNumber;
}

public void setPageNumber(int pageNumber)
{
this.pageNumber = pageNumber;
}
}
}
2 changes: 1 addition & 1 deletion src/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="Castle.Core" version="4.3.1" targetFramework="net45" />
<package id="GroupDocs.Editor" version="20.8.0" targetFramework="net45" />
<package id="GroupDocs.Editor" version="20.10.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.2.7" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
Expand Down