Skip to content
Merged
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
3 changes: 0 additions & 3 deletions AWS/AWSElasticBeanstalkSample/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public IActionResult BlinkToPDF()
//Initialize HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings settings = new BlinkConverterSettings();
//Set command line arguments to run without the sandbox.
settings.CommandLineArguments.Add("--no-sandbox");
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
//Set Blink viewport size.
settings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
//Assign Blink settings to the HTML converter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public string FunctionHandler(string input, ILambdaContext context)
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

blinkConverterSettings.BlinkPath = Path.GetFullPath("BlinkBinariesAws");
blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");
blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");

blinkConverterSettings.AdditionalDelay = 3000;

Expand Down
3 changes: 0 additions & 3 deletions AWS/NetCoreAWSFargate/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public IActionResult BlinkToPDF()
//Initialize HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings settings = new BlinkConverterSettings();
//Set command line arguments to run without the sandbox.
settings.CommandLineArguments.Add("--no-sandbox");
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
//Set Blink viewport size.
settings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
//Assign Blink settings to the HTML converter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public ActionResult ExportToPDF()
//Initialize HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
//Set command line arguments to run without sandbox.
blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");
blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
htmlConverter.ConverterSettings = blinkConverterSettings;
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");
MemoryStream outputStream = new MemoryStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public ActionResult ExportToPDF()
//Initialize HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
BlinkConverterSettings settings = new BlinkConverterSettings();
//Set command line arguments to run without the sandbox.
settings.CommandLineArguments.Add("--no-sandbox");
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
//Assign Blink settings to the HTML converter.
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Func

//Initialize the HTML to PDF converter with the Blink rendering engine.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);

//Set command line arguments to run without sandbox.
settings.CommandLineArguments.Add("--no-sandbox");
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
settings.BlinkPath = blinkBinariesPath;
//Assign BlinkConverter settings to the HTML converter
htmlConverter.ConverterSettings = settings;
Expand Down
3 changes: 0 additions & 3 deletions Docker/HTML_to_PDF_docker/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public ActionResult ExportToPDF()
//Initialize HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
BlinkConverterSettings settings = new BlinkConverterSettings();
//Set command line arguments to run without sandbox.
settings.CommandLineArguments.Add("--no-sandbox");
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
//Set Blink viewport size.
settings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
//Assign Blink settings to HTML converter.
Expand Down
4 changes: 0 additions & 4 deletions Linux/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ static void Main(string[] args)

BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();

blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");

blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");

//Assign Blink converter settings to HTML converter
htmlConverter.ConverterSettings = blinkConverterSettings;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using Microsoft.AspNetCore.Mvc;
using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using Syncfusion_HTMLtoPDF.Models;
using System.Diagnostics;
using System.IO;

namespace Syncfusion_HTMLtoPDF.Controllers
{
public class HomeController : Controller
{
private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;
public HomeController(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
}
public IActionResult Index()
{
return View();
}
public IActionResult ConvertToPdf()
{

string fileName = "HtmlSample_Thousand";
//string fileName = "HtmlSample";
//string fileName = "HtmlSample_FiveHundred";
//string fileName = "HtmlSample_Hundred";
double totalTime = 0;
string ConsoleLog = "";
MemoryStream stream = null;
for (int i = 0; i < 5; i++)
{
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
BlinkConverterSettings settings = new BlinkConverterSettings();
settings.AdditionalDelay = 0;
settings.Margin.All = 0;
settings.Scale = 1.0f;
htmlConverter.ConverterSettings = settings;
string htmlFilePath = Path.Combine(_hostingEnvironment.WebRootPath,"Data", fileName + ".html");
Stopwatch watch = new Stopwatch();
watch.Start();
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert(htmlFilePath);
watch.Stop();
totalTime += watch.Elapsed.TotalSeconds;
ConsoleLog+=(i + 1) + " conversion time:" + watch.Elapsed.TotalSeconds+"\n";

if (i == 0)
{
using (stream = new MemoryStream())
{
document.Save(stream);
document.Close(true);
}
}
}
double averageTime = totalTime / 5;
ConsoleLog+="Average conversion time:" + averageTime+"\n";
System.IO.File.WriteAllText(Path.Combine(_hostingEnvironment.WebRootPath, "Data", fileName + ".txt"), ConsoleLog);
return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf");
}

public IActionResult Privacy()
{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Syncfusion_HTMLtoPDF.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}
27 changes: 27 additions & 0 deletions Performance_Testing/Syncfusion_HTMLtoPDF/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:65381",
"sslPort": 44317
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5083",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7010;http://localhost:5083",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.HtmlToPdfConverter.Net.Windows" Version="*" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
</PropertyGroup>
</Project>
25 changes: 25 additions & 0 deletions Performance_Testing/Syncfusion_HTMLtoPDF/Syncfusion_HTMLtoPDF.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syncfusion_HTMLtoPDF", "Syncfusion_HTMLtoPDF.csproj", "{02031B6D-6142-4AE3-BB08-E111536F1131}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{02031B6D-6142-4AE3-BB08-E111536F1131}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02031B6D-6142-4AE3-BB08-E111536F1131}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02031B6D-6142-4AE3-BB08-E111536F1131}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02031B6D-6142-4AE3-BB08-E111536F1131}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {75287BD0-75CD-42F6-A03B-9F7B108D23D0}
EndGlobalSection
EndGlobal
13 changes: 13 additions & 0 deletions Performance_Testing/Syncfusion_HTMLtoPDF/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@{
ViewData["Title"] = "Home Page";
}

@{
Html.BeginForm("ConvertToPdf", "Home", FormMethod.Post);
{
<div>
<input type="submit" value="Convert HTML to PDF" />
</div>
}
Html.EndForm();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>

<p>Use this page to detail your site's privacy policy.</p>
25 changes: 25 additions & 0 deletions Performance_Testing/Syncfusion_HTMLtoPDF/Views/Shared/Error.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Syncfusion_HTMLtoPDF</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/Syncfusion_HTMLtoPDF.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Syncfusion_HTMLtoPDF</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>

<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - Syncfusion_HTMLtoPDF - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
Loading