Skip to content

Commit d6146e2

Browse files
Added sample
1 parent c66bfd3 commit d6146e2

File tree

77 files changed

+74386
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+74386
-0
lines changed

Controllers/HomeController.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using PPTtoPDF.Models;
3+
using System.Diagnostics;
4+
using Syncfusion.Presentation;
5+
using Syncfusion.PresentationRenderer;
6+
using Syncfusion.Pdf;
7+
8+
namespace PPTtoPDF.Controllers
9+
{
10+
public class HomeController : Controller
11+
{
12+
private readonly ILogger<HomeController> _logger;
13+
14+
public HomeController(ILogger<HomeController> logger)
15+
{
16+
_logger = logger;
17+
}
18+
19+
public IActionResult Index()
20+
{
21+
return View();
22+
}
23+
24+
public IActionResult ConvertToPDF()
25+
{
26+
using(FileStream input = new FileStream(Path.GetFullPath("Data/Template.pptx"), FileMode.Open, FileAccess.Read))
27+
{
28+
using (IPresentation pptxDoc = Presentation.Open(input))
29+
{
30+
PresentationToPdfConverterSettings settings = new PresentationToPdfConverterSettings();
31+
//settings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B;
32+
//settings.AutoTag = true;
33+
settings.PublishOptions = PublishOptions.NotesPages;
34+
PdfDocument pdfDocument = PresentationToPdfConverter.Convert(pptxDoc, settings);
35+
MemoryStream ms = new MemoryStream();
36+
pdfDocument.Save(ms);
37+
ms.Position = 0;
38+
return File(ms, "application/pdf", "PPTtoPDF.pdf");
39+
}
40+
}
41+
}
42+
43+
public IActionResult Privacy()
44+
{
45+
return View();
46+
}
47+
48+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
49+
public IActionResult Error()
50+
{
51+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
52+
}
53+
}
54+
}

Data/Template.pptx

73.9 KB
Binary file not shown.

Models/ErrorViewModel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace PPTtoPDF.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}

PPTtoPDF.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.PresentationRenderer.Net.Core" Version="22.2.12" />
11+
</ItemGroup>
12+
13+
</Project>

PPTtoPDF.csproj.user

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
5+
</PropertyGroup>
6+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
7+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
8+
</PropertyGroup>
9+
</Project>

Program.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
builder.Services.AddControllersWithViews();
5+
6+
var app = builder.Build();
7+
8+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Your license key");
9+
10+
// Configure the HTTP request pipeline.
11+
if (!app.Environment.IsDevelopment())
12+
{
13+
app.UseExceptionHandler("/Home/Error");
14+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
15+
app.UseHsts();
16+
}
17+
18+
app.UseHttpsRedirection();
19+
app.UseStaticFiles();
20+
21+
app.UseRouting();
22+
23+
app.UseAuthorization();
24+
25+
app.MapControllerRoute(
26+
name: "default",
27+
pattern: "{controller=Home}/{action=Index}/{id?}");
28+
29+
app.Run();

Properties/launchSettings.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:39031",
7+
"sslPort": 44368
8+
}
9+
},
10+
"profiles": {
11+
"http": {
12+
"commandName": "Project",
13+
"dotnetRunMessages": true,
14+
"launchBrowser": true,
15+
"applicationUrl": "http://localhost:5044",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"https": {
21+
"commandName": "Project",
22+
"dotnetRunMessages": true,
23+
"launchBrowser": true,
24+
"applicationUrl": "https://localhost:7073;http://localhost:5044",
25+
"environmentVariables": {
26+
"ASPNETCORE_ENVIRONMENT": "Development"
27+
}
28+
},
29+
"IIS Express": {
30+
"commandName": "IISExpress",
31+
"launchBrowser": true,
32+
"environmentVariables": {
33+
"ASPNETCORE_ENVIRONMENT": "Development"
34+
}
35+
}
36+
}
37+
}

Views/Home/Index.cshtml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@{
2+
ViewData["Title"] = "Home Page";
3+
}
4+
5+
<input type="button" value="PPT to PDF" onclick="location.href='@Url.Action("ConvertToPDF","Home")'" />

Views/Home/Privacy.cshtml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
ViewData["Title"] = "Privacy Policy";
3+
}
4+
<h1>@ViewData["Title"]</h1>
5+
6+
<p>Use this page to detail your site's privacy policy.</p>

Views/Shared/Error.cshtml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@model ErrorViewModel
2+
@{
3+
ViewData["Title"] = "Error";
4+
}
5+
6+
<h1 class="text-danger">Error.</h1>
7+
<h2 class="text-danger">An error occurred while processing your request.</h2>
8+
9+
@if (Model.ShowRequestId)
10+
{
11+
<p>
12+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
13+
</p>
14+
}
15+
16+
<h3>Development Mode</h3>
17+
<p>
18+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
19+
</p>
20+
<p>
21+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
22+
It can result in displaying sensitive information from exceptions to end users.
23+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
24+
and restarting the app.
25+
</p>

0 commit comments

Comments
 (0)